watonomous.github.io

  1. Electrical Division
  2. Electrical Division Home
  3. Telemetry Group
  4. CAN Interface and Software Design Document

[ Electrical Division : ROS/CAN Interface Testing Plan ]

Created by [ Avery Chiu] on Jan 08, 2021

All the scripts in the CAN Interface repo under ros-interface (within the ros-interface branch) still need to be tested. These scripts are located here: https://git.uwaterloo.ca/WATonomous/can-interface/-/tree/ros-interface/ROSInterface]

Make sure you are familiar with ROS nodes, these scripts are basically publisher/listener scripts. Below are some details:

ROS.py is an abstract class that acts as a blueprint for the publisher/listener scripts. No explicit test has to be written for this since this will be implicitly tested when writing unit tests for the publisher and listener scripts.

The publisher scripts receive CAN messages from the CAN bus and sends it to the path-planning team using ROS. We have to check that these scripts can properly grab CAN data and send it. See test_PublishHS.py for an example of how this is done. The steps are as follows:

  1. Start a thread, we use threads to mimic messages firing off at the same time. For more information see here: https://realpython.com/intro-to-python-threading/
  2. Encode the CAN message we want using DBC file
  3. Make sure our publish script is running then send a CAN message
  4. Subscribe to the nodes that the publish script is publishing too
  5. Make sure we get the correct CAN messages

The listener scripts are subscribed to a ROS node. They receive messages from the path-planning team and then encode that message to be sent as a CAN message (this can be seen in 

To test the scripts, we need to perform the following:

  1. Start a thread 
  2. Ensure that the listener script is running
  3. Write to the nodes the listener is listening to, eg you could send a message to steering telling it to turn the wheel 45 degrees clockwise
  4. Read from the CAN bus to check that the message was sent properly. 

To learn more about receiving CAN messages, take a look at the documentation.

https://python-can.readthedocs.io/en/master/interfaces/socketcan.html

https://confluence.watonomous.ca/display/ED/Intro+to+CAN 

We also already have unit tests in the CAN interface that do something similar shown here within the same repo https://git.uwaterloo.ca/WATonomous/can-interface/-/blob/ros-interface/CANBus/tests/Scripts/basic.py

Document generated by Confluence on Nov 28, 2021 22:40

Atlassian