logging_tutlesim
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
logging_tutlesim [2013/06/25 13:07] – created bokal | logging_tutlesim [2016/05/19 09:19] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Logging | + | ===== Logging turtlesim data ===== |
This is a simple example to show logging of pose and velocity information from running the '' | This is a simple example to show logging of pose and velocity information from running the '' | ||
==== 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 | + | rosrun turtlesim |
- | rosrun turtlesim | + | rosrun turtlesim |
- | rosrun | + | rosrun |
# use Ctrl + C to stop | # use Ctrl + C to stop | ||
| | ||
==== Accessing the data ==== | ==== Accessing the data ==== | ||
- | The data that has been logged can be accessed via may ways, directly using terminal mongo client or via the language APIs. | + | The data that has been logged can be accessed via may ways, directly using terminal mongo client or via the language APIs. These are each shown below; |
+ | |||
+ | === Via the mongo terminal client === | ||
+ | This is installed when you get the mongodb package installed on the system. | ||
+ | mongo # alternatively, | ||
+ | # you should see an interface like the following | ||
+ | | ||
+ | | ||
+ | # change to the ros database using | ||
+ | > use roslog | ||
+ | | ||
+ | # see a list of databases using | ||
+ | > show dbs | ||
+ | | ||
+ | | ||
+ | # see the list of items stored using the following | ||
+ | > db.getCollectionNames() | ||
+ | [ | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ] | ||
+ | # further commands are given in standard mongo cheatsheets | ||
+ | > | ||
+ | |||
+ | === Via a python API === | ||
+ | The full documentation of the python API is available online at [[http:// | ||
+ | import pymongo | ||
+ | mclient = pymongo.Connection() | ||
+ | db = mclient[' | ||
+ | # get the collections | ||
+ | db.collection_names() | ||
+ | [u' | ||
+ | command_velocity' | ||
+ | # show all the data in the database | ||
+ | docs = db[' | ||
+ | for d in docs: | ||
+ | print d | ||
+ | # this displays a long list with elements like these | ||
+ | {u' | ||
+ | 440479278564, | ||
+ | bjectId(' | ||
+ | ded': 1372164044.44448} | ||
+ | {u' | ||
+ | 440479278564, | ||
+ | bjectId(' | ||
+ | ded': 1372164044.460494} | ||
+ | |||
+ | # querying can be done directly on these. e.g. | ||
+ | q = db[' | ||
+ | q.count() | ||
+ | 1 # which is exactly the last recording as shown in the data snippet above | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
| | ||
logging_tutlesim.1372165672.txt.gz · Last modified: 2016/05/19 09:18 (external edit)