Software sources for the UdeS 1/10th autonomous car platform
The project is created with:
- Python 3.8
- Arduino programming language
- ROS 2
To be able to test our code, there are a few requirements.
- RaceCar of the Université de Sherbrooke
- Logitech Wireless Gamepad F710 (DirectInput Mode)
-
For Raspberry Pi on RaceCar, we provide RPI4 images with everything already installed, see this page to flash your RPI.
-
For Desktop/Laptop development, see this section to setup ROS in a virtual machine or in a dual boot with Ubuntu 22.04
-
Click here to download the default virtual machine, see this section for how to import it in Virtual box Use the VM to show topics and view them in RVIZ to limit the usage of the RaspberryPi. You might need to change the ROS_DOMAIN_ID on both machine before using it :
export ROS_DOMAIN_ID = X
- Hardware Connections
- USB Hub woes
- Steering Offset
- Remote Connection (SSH/VNC)
- ROS2 on multiple computers (ROS_IP)
- Simulated environment (Gazebo)
- The RaceCar batteries
- Charging the Anker battery
- Charging the Traxxas battery
- The Killswitch
In the graph, you can see a representation of the communication between the nodes and the topics of the most basic working mode: using the base launch file teleop.launch.
The RaceCar has many operating modes that allow you to test different functionnalities. The ROS controller Node, which control commands to the motor and the steering servo, has multiple high-level mode that are selected by joystick inputs (see Controller modes table for more details). For instance, open-loop, closed-loop in velocity, closed-loop in position modes are available for both the propulsion and the steering. The Arduino has also multiple internal low-level modes (different than the high-level ones!!!) that are selected by the ROS controller Node. Empty operating mode templates are available in the source code for you to test custom control modes.
- Follow those instructions to flash your Raspberry Pi with a pre-built image.
- Connect the battery to Raspberry Pi.
- Flash the Arduino (need to be done only 1 time):
- Connect the Arduino mega 2560 of the RaceCar to Raspberry Pi if not already done.
- Flash the Arduino mega 2560 with the firmware file Controller.ino using Arduino IDE (with Tools->Board: select "Arduino Mega or Mega 2560" as target).
- Turn on the motors by flipping the switch on the left side of the car. A green light will turn on.
- From a terminal (
ctrl+alt+t
), launch ROS with the launch file teleop.launch:$ ros2 launch racecar_bringup teleop.launch
- To visualize the racecar in rviz:
$ ros2 launch racecar_navigation rviz.launch
- Enable the joystick by performing an input combination below to start.
- Enjoy!
The high-level mode is the operating mode of the "controller" node running on the rasberry pi. The high-level mode is selected in the "teleop" node, that translate joystick buttons into a "ctl_ref" message. The mode is placed in the "ctl_ref.linear.z" channel.
Joystick inputs: LB is used as a deadman switch and must be always pressed for the car to operate. Make sure the switch mode behind the gamepad is on D and not X.
High-level Mode | Input buttons | Function |
---|---|---|
-1 | None | Disabled |
0 | LB |
Closed-loop velocity, open-loop steering |
1 | LB + RB |
Fully Open-loop |
2 | LB + RT |
Closed-loop position, open-loop steering |
3 | LB + A |
Closed-loop velocity, closed-loop steering |
4 | LB + B |
Closed-loop position, closed-loop steering |
5 | LB + X |
Closed-loop velocity, closed-loop steering |
6 | LB + Y |
Reset encoder command |
7 | LB + LY |
Empty Template |
8 | LB + Croos key Up/Down |
Empty Template |
NaN | LB + LT |
Joystick-based control disabled (no ctl_ref published) |
The low-level mode is the operating mode of the Arduino. The low-level mode is selected in the "controller" node running on the rasberry pi. The mode is placed in the "prop_cmd.linear.z" channel.
Low-level Mode | Function |
---|---|
0 | Disabled |
1 | Open-loop PWM control |
2 | Closed-loop velocity (based on wheel-encoder feedback) |
2 | Closed-loop position (based on wheel-encoder feedback) |
4 | Reset encoder command |