Пример #1
0
def read_messages(path):
    with rosbag.Bag(path) as bag:
        return [{
            'topic': topic,
            'msg': convert_ros_message_to_dictionary(msg),
            'time': t.to_time()
        } for topic, msg, t in bag.read_messages()]
Пример #2
0
 def srv_store_object_cb(self,  req):
     
     db = dataset.connect('sqlite:////' + self.db_path)
     objects = db['objects']
     bb_json = json.dumps(message_converter.convert_ros_message_to_dictionary(req.bbox))
     objects.insert(dict(name=req.name, model_url=req.model_url, obj_id=req.obj_id,  type=req.type,  bb=bb_json))
     resp =storeObjectResponse()
     resp.success = True
     return resp
Пример #3
0
 def srv_store_program_cb(self,  req):
     
     db = dataset.connect('sqlite:////' + self.db_path)
     programs = db['programs']
     prog_json = json.dumps(message_converter.convert_ros_message_to_dictionary(req.program))
     resp = storeProgramResponse()
     resp.success = True
     programs.upsert(dict(program_id=req.program.id,  name=req.program.name,  json=prog_json),  ['program_id'])
     return resp
def convert_ros_message_to_json(message):
    """
    Takes in a ROS message and returns a JSON-formatted string.

    Example:
        ros_message = std_msgs.msg.String(data="Hello, Robot")
        json_message = convert_ros_message_to_json(ros_message)
    """
    dictionary = message_converter.convert_ros_message_to_dictionary(message)
    json_message = json.dumps(dictionary)
    return json_message
def extract_data(bag, topic, directory):
    """
    Spew messages to a file

    args:
        topic -> topic to extract and print to txt file
    """
    output_dir = os.path.join(directory, topic.replace('/', '') + '.yaml')
    print 'Printing {0}'.format(topic)
    print 'Output file will be called {0}.'.format(directory.split('/')[-1])

    output_file = open(output_dir, "w")

    for topic, msg, t in bag.read_messages(topics=topic):
        created_dictionary = message_converter.convert_ros_message_to_dictionary(
            msg)
        yaml.dump(created_dictionary, output_file, default_flow_style=False)

    output_file.close()
    print 'DONE'
Пример #6
0
 def robot_pose_callback(self, msg):
     attr_dict = message_converter.convert_ros_message_to_dictionary(msg)
     json_file.json_write("/home/eaibot/dashgo_ws/src/dashgo/dashgo_nav/maps/current_pose.json", attr_dict)