User Tools

Site Tools


logging_tutlesim

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
logging_tutlesim [2013/06/25 13:21] bokallogging_tutlesim [2016/05/19 09:19] (current) – external edit 127.0.0.1
Line 4: Line 4:
 ==== Logging the data ==== ==== Logging the data ====
 Start the turtlesim and log all the topics using the following sets of commands Start the turtlesim and log all the topics using the following sets of commands
-  rosrun turtlesim turtlesim +  rosrun turtlesim turtlesim_node 
-  rosrun turtlesim turtle_tel # for keyboard teleop to get changing data +  rosrun turtlesim turtle_teleop_key # for keyboard teleop to get changing data 
-  rosrun mongodb mongodb_log -a # for all topics. check help for more options+  rosrun mongodb_log mongodb_log -a # for all topics. check help for more options
   # use Ctrl + C to stop   # use Ctrl + C to stop
      
Line 38: Line 38:
 === Via a python API === === Via a python API ===
 The full documentation of the python API is available online at [[http://api.mongodb.org/python/current/|http://api.mongodb.org/python/current/]]. Below is a simple example usage: The full documentation of the python API is available online at [[http://api.mongodb.org/python/current/|http://api.mongodb.org/python/current/]]. Below is a simple example usage:
 +  import pymongo 
 +  mclient = pymongo.Connection() 
 +  db = mclient['roslog'
 +  # get the collections 
 +  db.collection_names() 
 +  [u'turtle1_color_sensor', u'system.indexes', u'turtle1_pose', u'turtle1_ 
 +  command_velocity'
 +  # show all the data in the database 
 +  docs = db['turtle1_pose'].find() 
 +  for d in docs: 
 +    print d 
 +  # this displays a long list with elements like these 
 +  {u'__topic': u'/turtle1/pose', u'linear_velocity': 0.0, u'theta': 1.9824 
 +  440479278564, u'y': 8.26992130279541, u'x': 4.029432773590088, u'_id':
 +  bjectId('51c98fcca6c646570b000901'), u'angular_velocity': 0.0, u'__recor 
 +  ded': 1372164044.44448} 
 +  {u'__topic': u'/turtle1/pose', u'linear_velocity': 0.0, u'theta': 1.9824 
 +  440479278564, u'y': 8.26992130279541, u'x': 4.029432773590088, u'_id':
 +  bjectId('51c98fcca6c646570b000902'), u'angular_velocity': 0.0, u'__recor 
 +  ded': 1372164044.460494} 
 +   
 +  # querying can be done directly on these. e.g. 
 +  q = db['turtle1_pose'].find({'__recorded':{'$gt' : 1372164044.44448}})  
 +  q.count() 
 +  1 # which is exactly the last recording as shown in the data snippet above 
 +   
 +   
 +  
        
  
logging_tutlesim.1372166513.txt.gz · Last modified: 2016/05/19 09:18 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki