def publish(topic, instructions=None):
if type(topic) not in [str, nb_channels.Messages]:
rospy.logerr("** Topic must be of type string or Messages in order to publish to cable **")
return False
if instructions and type(instructions) is not dict:
rospy.logerr("** Instructions must be of type dictionary in order to publish to cable **")
return False
# Properly format topic string
topic_val = topic if type(topic) is str else topic.value
try:
rospy.wait_for_service('ui_send', 0.1)
client = UIClient()
return client.send(
topic_val,
json.dumps(instructions)
)
except rospy.ROSException:
return UIMessageResponse(success=False)
评论列表
文章目录