def _start_local_endpoint(self): try: msg_class = get_message_class(self._action_type + 'Action') if msg_class == None: e = 'Error: message class ' + self._action_type + 'Action is not available in local machine' print(e) rospy.logerr('message class ' + self._action_type + 'Action is not available in local machine') return self._msg_class_feedback = get_message_class( self._action_type + 'ActionFeedback') #self._topic_type.split('Action$ if self._msg_class_feedback == None: e = 'Error: message class ' + self._action_type + 'ActionFeedback is not available in local machine' print(e) rospy.logerr( 'message class ' + self._action_type + 'ActionFeedback is not available in local machine') return self._msg_class_status = get_message_class( 'actionlib_msgs/GoalStatusArray' ) #self._topic_type.split('Action$ if self._msg_class_status == None: e = 'Error: message class actionlib_msgs/GoalStatusArray is not available in local machine' print(e) rospy.logerr( 'message class actionlib_msgs/GoalStatusArray is not available in local machine' ) return self._msg_class_result = get_message_class( self._action_type + 'ActionResult') #self._topic_type.split('Action$ if self._msg_class_result == None: e = 'Error: message class ' + self._action_type + 'ActionResult is not available in local machine' print(e) rospy.logerr('message class ' + self._action_type + 'ActionResult is not available in local machine') return except: print('Error with action server ' + self._remote_action) rospy.logerr('Action server ' + self._remote_action + ' is not available in local machine') return self._as = actionlib.SimpleActionServer(self._remote_action, msg_class, execute_cb=self.execute_cb, auto_start=False) self._as.start() data = {}
def _start_local_endpoint(self): msg_class=get_message_class(self._topic_type) if msg_class==None : e='Error: message class '+self._message_type+' is not available in local machine' self.stop() print(e) else : self._local_ros_sub = rospy.Subscriber(self._local_topic,msg_class, self._receive_message)
def _start_local_endpoint(self): msg_class = get_message_class(self._topic_type) if msg_class == None: e = 'Error: message class ' + self._message_type + ' is not available in local machine' self.stop() print(e) else: self._local_ros_pub = rospy.Publisher(self._local_topic, msg_class, queue_size=10)
def _on_result(self, data, status, header): # d={'header': header,'status': status,'result': data} self._result = fill_ros_message( get_message_class(self._action_type + 'Result')(), data) # self._text = status['text'] if status['status'] == 4: print('R!Abort') self.abort = True elif status['status'] == 3: print('R!Goal Reached') self.success = True elif status['status'] == 1: print('R!Active') elif status['status'] == 2: print('R!Preempted') self.preempt = True
def _start_local_endpoint(self): try: msg_class = get_message_class(self._topic_type) if msg_class == None: e = 'Error: messagee class ' + self._topic_type + ' is not available in local machine' print(e) rospy.logerr('messagee class ' + self._topic_type + ' is not available in local machine') return except: e = 'Error: local topic type of ' + self._local_topic + ' is not available' rospy.logerr('messagee class ' + self._topic_type + ' is not available in local machine') return self._local_ros_sub = rospy.Subscriber(self._local_topic, msg_class, self._receive_message)
def _init_ros_publisher(self): """_init_ros_publisher""" if self.debug: log_level = rospy.DEBUG else: log_level = rospy.INFO _uri = self.ros_endpoint.uri _node_name = self.ros_endpoint.name _msg_type = self.ros_endpoint.msg_type _msg_pkg = _msg_type.split('/')[0] _msg_cls = _msg_type.split('/')[1] msg_cls = get_message_class(_msg_type) self._ros_pub = rospy.Publisher(_uri, msg_cls, queue_size=10) rospy.loginfo('ROS Publisher <{}> ready!'.format(_uri))
def _start_local_endpoint(self): try: msg_class = get_message_class(self._topic_type) if msg_class == None: e = 'Error : message class ' + self._topic_type + ' is not available in local machine' print(e) rospy.logerr('message class ' + self._topic_type + ' is not available in local machine') return except: e = 'Error : local topic type of ' + self._local_topic + ' is not available' print(e) rospy.logerr('message class ' + self._topic_type + ' is not available in local machine') return self._local_ros_pub = rospy.Publisher(self._local_topic, msg_class, queue_size=10)
def _init_ros_subscriber(self): """_init_ros_subscriber""" if self.debug: log_level = rospy.DEBUG else: log_level = rospy.INFO _uri = self.ros_endpoint.uri _node_name = self.ros_endpoint.name _msg_type = self.ros_endpoint.msg_type _msg_pkg = _msg_type.split('/')[0] _msg_cls = _msg_type.split('/')[1] msg_cls = get_message_class(_msg_type) # Initialize ROS Subscriber self._ros_sub = rospy.Subscriber(_uri, msg_cls, self._ros_sub_callback) rospy.loginfo('ROS Subscriber <{}> ready!'.format(_uri))
def _on_feedback(self, data, status, header): d = {'header': header, 'status': status, 'feedback': data} feedback = fill_ros_message( get_message_class(self._action_type + 'Feedback')(), data) self._as.publish_feedback(feedback)
def _start_local_endpoint(self): self._local_ros_pub = rospy.Publisher(self._local_topic, get_message_class( self._topic_type), queue_size=10)
def test_get_message_class(self): from sensor_msgs.msg import Image msg_cls = get_message_class('sensor_msgs/Image') msg = msg_cls() self.assertIsInstance(msg, Image)