Pypot used the Python’s builtin logging module for logging. For details on how to use this module please refer to Python’s own documentation or the one on django webstite. Here, we will only describe what pypot is logging and how it is organised (see section Logging structure). We will also present a few examples on how to use pypot logging and parse the information (see section Using Pypot’s logging).
Pypot is logging information at all different levels:
Note
As you probably do not want to log everything (Pypot is sending a lot of messages!!!), you have to select in the logging structure what is relevant in your program and define it in your logging configuration.
Pypot’s logging naming convention is following Pypot’s architecture. Here is the detail of what Pypot is logging with the associated logger’s name:
As an example of what you can do with the logging system, here is how you can check the “real” update frequency of a loop primitive.
First, you have to define a logging config. As you can see, here we specify that we only want the log coming form ‘pypot.primitive’ and the message is formatted so we only keep the timestamp:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'time': {
'format': '%(asctime)s',
},
},
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'pypot.log',
'formatter': 'time',
},
},
'loggers': {
'pypot.primitive': {
'handlers': ['file', ],
'level': 'DEBUG',
},
},
}
Then, we just have to write a simple program, where for instance we run our dummy primitive for ten seconds:
import pypot.robot
[...]
if __name__ == '__main__':
logging.config.dictConfig(LOGGING)
r = pypot.robot.from_config(ergo_config)
r.start_sync()
class DummyPrimitive(LoopPrimitive):
pass
p = DummyPrimitive(r, 50)
p.start()
time.sleep(10)
p.stop()
The execution of the program above will create a file named ‘pypot.log’ where each line corresponds to the timestamp of each primitive update. This file can then be easily parsed:
t = []
with open('pypot.log') as f:
for l in f.readlines():
d = datetime.datetime.strptime('%Y-%m-%d %H:%M:%S,%f\n')
t.append(d)
t = numpy.array(t)
dt = map(lambda dt: dt.total_seconds(), numpy.diff(t))
dt = numpy.array(dt) * 1000
print numpy.mean(dt), numpy.std(dt)
plot(dt)
show()
Herborist is a graphical tool that helps you detect and configure motors before using them in your robot.
Warning
Herborist is entirely written in Python but requires PyQt4 to run.
More precisely, Herborist can be used to:
You can directly launch herborist by running the herborist command in your terminal.
Note
When you install PyPot with the setup.py, herborist is automatically added to your $PATH. You can call it from anywhere thanks to the command:
herborist
You can always find the script in the folder $(PYPOT_SRC)/pypot/tools/herborist.