We have introduced a new debugging tool for Stretch Body called Firmware Trace. To use it you will need to update to at least
- Stretch Factory v0.3.18
- Stretch Body v0.4.28
- Stepper.v0.3.0p2
- Wacc.v0.3.0p2
- Pimu.v0.3.0p2
Note: This tool is recommended for advanced users only
The Firmware Trace tool allows you to log the Status data at the full control rate on the robot Arduino micro-controllers. For example, on the four stepper drives the Status message is logged at 1Khz.
This can be useful to capture and debug transient events that are short in duration and therefore not visible using the normal Stretch Body Python status messages.
To use the tool, you
- Enable the trace function
- Wait for the event to happen that you care about
- Disable the trace
- Read back the trace data from the device
Note: Reading out the trace from the Arduino can take several seconds and should be considered an offline function
For example:
#!/usr/bin/env python3
import time
import stretch_body.wacc
w=stretch_body.wacc.Wacc()
w.startup()
w.pull_status()
w.enable_firmware_trace()
w.push_command()
time.sleep(1.0)
w.disable_firmware_trace()
w.push_command()
trace=w.read_firmware_trace()
print('Trace recieved %d status messages'%len(trace))
print(trace[0]['status'])
w.stop()
This returns 250 status messages that are sampled at 1Khz on the Wacc. It prints out the first one.
In addition, there is a tool REx_trace_firmware.py
that provides a menu interface to generate trace data and plot out the status fields.
For example, the Wacc trace can be recorded and displayed:
And we plot the AX value of the accelerometer as read at 1Khz:
Note: By default the firmware will trace the Status message. However advanced users will find that other types of data can be configured to pass back as well.