Skip to content

Commit

Permalink
Working on Read function
Browse files Browse the repository at this point in the history
  • Loading branch information
Josht8601 committed Oct 17, 2023
1 parent 76a8024 commit 8c6b83e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions mil_common/utils/mil_tools/scripts/preflight/preflightFileIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# readTests(filename)
# reads and runs all the tests in the file.
# returns whether each test pass or fail
import rospy
import rostopic


def writeTests(filename, topicsToCheck):
Expand Down Expand Up @@ -50,13 +52,23 @@ def deleteTests(filename, topicsToCheck):
def readTests(filename):
tests = open(filename)
lines = tests.readlines()
dataTypes = []
for i in range(len(lines)):
lines[i] = lines[i][:-1]
TopicType, topic_str, _ = rostopic.get_topic_class(lines[i])
dataTypes.append(TopicType)
lines[i] = topic_str
rospy.Subscriber(lines[i], dataTypes[i], some_callback)


def some_callback(msg):
rospy.loginfo("Got the message: " + str(msg))

print(lines)
# We need to call the ros topic and verify the data WIP


writeTests("SubChecklist.txt", ["Test", "testing"])
deleteTests("SubChecklist.txt", ["testing"])
readTests("SubChecklist.txt")
if __name__ == "__main__":
rospy.init_node("topic_publisher_checker")
writeTests("SubChecklist.txt", ["dvl", "odom"])
deleteTests("SubChecklist.txt", ["testing"])
readTests("SubChecklist.txt")

0 comments on commit 8c6b83e

Please sign in to comment.