def test_json_format_from_ros_msg(self):
     msg_typ_info = {}
     msg_typ_info['HelloMessage'] = 'rospy_message_transporter'
     msg_typ_info['HeartbeatMessage'] = 'rospy_message_transporter'
     message_formatter = JsonFormatter('messageType',msg_typ_info)
     msg = HeartbeatMessage()
     msg.droneID = "UAV123"
     msg.sessionID = "SE123"
     msg.batteryLevel = 0.7
     msg.status = 0
     msg.latitude = 40
     msg.longitude = 40
     msg.altitude = 40
     json = message_formatter.format_from_ros_msg(msg)
     expected_json = '{"status": 0, "droneID": "UAV123", "altitude": 40, "longitude": 40, "sessionID": "SE123", "messageType": "", "latitude": 40, "batteryLevel": 0.7}'
     self.assertEqual(json, expected_json)
Esempio n. 2
0
 def test_json_format_from_ros_msg(self):
     msg_typ_info = {}
     msg_typ_info['HelloMessage'] = 'rospy_message_transporter'
     msg_typ_info['HeartbeatMessage'] = 'rospy_message_transporter'
     message_formatter = JsonFormatter('messageType', msg_typ_info)
     msg = HeartbeatMessage()
     msg.droneID = "UAV123"
     msg.sessionID = "SE123"
     msg.batteryLevel = 0.7
     msg.status = 0
     msg.latitude = 40
     msg.longitude = 40
     msg.altitude = 40
     json = message_formatter.format_from_ros_msg(msg)
     expected_json = '{"status": 0, "droneID": "UAV123", "altitude": 40, "longitude": 40, "sessionID": "SE123", "messageType": "", "latitude": 40, "batteryLevel": 0.7}'
     self.assertEqual(json, expected_json)
 def test_json_formatter_to_ros_msg(self):
     msg_typ_info = {}
     msg_typ_info['HelloMessage'] = 'rospy_message_transporter'
     msg_typ_info['HeartbeatMessage'] = 'rospy_message_transporter'
     message_formatter = JsonFormatter('messageType',msg_typ_info)
     json = '{"status": 0, "droneID": "UAV123", "altitude": 40, "longitude": 40, "sessionID": "SE123", "latitude": 40, "batteryLevel": 0.7, "messageType": "HeartbeatMessage"}'
     msg = message_formatter.format_to_ros_msg(json)
     expected_msg = HeartbeatMessage()
     expected_msg.droneID = "UAV123"
     expected_msg.sessionID = "SE123"
     expected_msg.batteryLevel = 0.7
     expected_msg.status = 0
     expected_msg.latitude = 40
     expected_msg.longitude = 40
     expected_msg.altitude = 40
     expected_msg.messageType = "HeartbeatMessage"
     self.assertEqual(msg, expected_msg)
     self.assertTrue(isinstance(msg, HeartbeatMessage))
 def test_publishing_handler_handle(self):
     try:
         pub_info = {}
         pub_info['HelloMessage'] = rospy.Publisher('Hello_Topic', HelloMessage, queue_size=10)
         pub_info['HeartbeatMessage'] = rospy.Publisher('Heartbeat_Topic', HeartbeatMessage, queue_size=10)
         pub_handler = PublishingHandler(pub_info)
         expected_msg = HeartbeatMessage()
         expected_msg.droneID = "UAV123"
         expected_msg.sessionID = "SE123"
         expected_msg.batteryLevel = 0.7
         expected_msg.status = 0
         expected_msg.latitude = 40
         expected_msg.longitude = 40
         expected_msg.altitude = 40
         expected_msg.messageType = "HeartbeatMessage"
         self.assertEqual(pub_handler.handle(expected_msg),"HeartbeatMessage")
     except rospy.ROSInterruptException:
         pass
Esempio n. 5
0
 def test_json_formatter_to_ros_msg(self):
     msg_typ_info = {}
     msg_typ_info['HelloMessage'] = 'rospy_message_transporter'
     msg_typ_info['HeartbeatMessage'] = 'rospy_message_transporter'
     message_formatter = JsonFormatter('messageType', msg_typ_info)
     json = '{"status": 0, "droneID": "UAV123", "altitude": 40, "longitude": 40, "sessionID": "SE123", "latitude": 40, "batteryLevel": 0.7, "messageType": "HeartbeatMessage"}'
     msg = message_formatter.format_to_ros_msg(json)
     expected_msg = HeartbeatMessage()
     expected_msg.droneID = "UAV123"
     expected_msg.sessionID = "SE123"
     expected_msg.batteryLevel = 0.7
     expected_msg.status = 0
     expected_msg.latitude = 40
     expected_msg.longitude = 40
     expected_msg.altitude = 40
     expected_msg.messageType = "HeartbeatMessage"
     self.assertEqual(msg, expected_msg)
     self.assertTrue(isinstance(msg, HeartbeatMessage))
 def test_publishing_handler_handle(self):
     try:
         pub_info = {}
         pub_info['HelloMessage'] = rospy.Publisher('Hello_Topic',
                                                    HelloMessage,
                                                    queue_size=10)
         pub_info['HeartbeatMessage'] = rospy.Publisher('Heartbeat_Topic',
                                                        HeartbeatMessage,
                                                        queue_size=10)
         pub_handler = PublishingHandler(pub_info)
         expected_msg = HeartbeatMessage()
         expected_msg.droneID = "UAV123"
         expected_msg.sessionID = "SE123"
         expected_msg.batteryLevel = 0.7
         expected_msg.status = 0
         expected_msg.latitude = 40
         expected_msg.longitude = 40
         expected_msg.altitude = 40
         expected_msg.messageType = "HeartbeatMessage"
         self.assertEqual(pub_handler.handle(expected_msg),
                          "HeartbeatMessage")
     except rospy.ROSInterruptException:
         pass