Skip to content

Commit

Permalink
WIP #15: Added locate function, removed small bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiaqi committed Mar 13, 2019
1 parent aacaadc commit 9409d3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions robot_misc_tools/scripts/update_configs/test_config.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cur_pose, Pose
cur_path, Path
drive_cmd, Twist
cur_pose,geometry_msgs,Pose
cur_path,nav_msgs,Path
drive_cmd,geometry_msgs,Twist
17 changes: 10 additions & 7 deletions robot_misc_tools/scripts/update_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
from geometry_msgs.msg import *
from nav_msgs.msg import *
from sensor_msgs.msg import *
from pydoc import locate

class UpdatePublisher:

#geometry_msgs.msg._Pose.Pose
def __init__ (self, topic_name, message_type):

#Initialize variable to be updated
self.latest_var = 0
self.latest_var = message_type()

#Initialize Publisher
self.publisher = rospy.Publisher('updates/' + topic_name, message_type, queue_size=0)
Expand Down Expand Up @@ -45,9 +47,11 @@ def load_config_file(file_name):

# Loop and append the updaters list with UpdatePublishers
for item in updaters_list:
comma = item.find(",")
topic_name = item[:comma]
message_type = item[comma+2:]
topic_name, message_package, message_type = item.split(",")

#Modify the string to locate
full_string = message_package + ".msg._" + message_type + "." + message_type
message_type = locate(full_string)
updaters.append(UpdatePublisher(topic_name, message_type))

return updaters
Expand All @@ -60,8 +64,8 @@ def load_config_file(file_name):
#Read a file containing a bunch of [topic name, message type] pairs, create an UpdatePublisher for each
updaters = UpdatePublisher.load_config_file("update_configs/test_config.csv")

#read values from server
update_rate = rospy.get_param("update_rate")
#read values from serverros
update_rate = rospy.get_param("update_rate", default=1)

#Log initialization message
rospy.loginfo("Update node initialized...")
Expand All @@ -71,7 +75,6 @@ def load_config_file(file_name):

# Send an update from each UpdatePublisher in updaters list
for item in updaters:
item.update_message()
item.publish_message()

rate.sleep()

0 comments on commit 9409d3d

Please sign in to comment.