Chart Helpers in the Artefacts Toolkit
The Artefacts Toolkit Chart helpers are designed to help you with visualising data received from topics while running tests.
Import with:
from artefacts_toolkit.chart import make_chart
Functions
Function Reference
make_chart
Creates an interactive HTML chart based on data from two provided topics.
make_chart(
filepath,
topic_x,
topic_y,
field_unit=None,
output_dir="output",
chart_name="chart",
file_type="rosbag"
output_format="html"
)
Parameters
Parameter | Type | Description | Default |
---|---|---|---|
filepath |
str |
Path to the data file (rosbag) | Required |
topic_x |
str |
Topic name for x-axis. Use “Time” to plot against time | Required |
topic_y |
str |
Topic name for y-axis. Use “Time” to plot against time | Required |
field_unit |
str |
Unit of measurement for the field data (e.g., “m/s”, “rad”) | None |
output_dir |
str |
Directory where the chart will be saved | "output" |
chart_name |
str |
Name of the generated chart file | "chart" |
file_type |
str |
Type of data file. Currently supports “rosbag” | "rosbag" |
output_format |
str |
Output file type. Choose from “html” or “csv” | "html" |
Returns
None
:
- When
output_format="html"
: Creates a plotly html chart<chart_name>.html
atoutput_dir
but doesn’t return any value. - When
output_format
=“csv” : Creates a csv file<chart_name>.csv at
output_dir` but doesn’t return any value. The Dashboard will automatically try to convert csv files to charts upon upload. Useful when wanting to keep file sizes down.
Note
- Currently only supports creating charts from rosbags
- When using “Time” as one of the topics, the function will automatically plot the other topic against that topic’s timestamp if available. If the topic does not have timestamps in its message structure, the rosbag’s time will be used.
Example
The following example adds the make_chart
function post shutdown, i.e after the test has completed and rosbag saved.
# my_test_file.launch.py
# test code
...
@launch_testing.post_shutdown_test()
class TestProcOutputAfterShutdown(unittest.TestCase):
def test_exit_code(self, rosbag_filepath):
make_chart(
rosbag_filepath,
"/odom.pose.pose.position.x",
"/odom.pose.pose.position.y",
field_unit="m",
chart_name="odometry_position",
)
Producing the following chart: