Skip to content

SherbyRobotics/racecar

Repository files navigation

racecar

Software sources for the UdeS 1/10th autonomous car platform

Table of contents

Technologies

The project is created with:

  • Python 3.8
  • Arduino programming language
  • ROS 2

Requirements

To be able to test our code, there are a few requirements.

Hardware

  • RaceCar of the Université de Sherbrooke
  • Logitech Wireless Gamepad F710 (DirectInput Mode)

Software

  • 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

Documentation

How it works

In the graph, you can see a representation of the communication between the nodes and the topics of the most basic working mode: 134103581-986b1f90-49de-4c44-837e-c3292f4de27f 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.

Launch

  1. Follow those instructions to flash your Raspberry Pi with a pre-built image.
  2. Connect the battery to Raspberry Pi.
  3. Flash the Arduino (need to be done only 1 time):
    1. Connect the Arduino mega 2560 of the RaceCar to Raspberry Pi if not already done.
    2. 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).
  4. Turn on the motors by flipping the switch on the left side of the car. A green light will turn on.
  5. From a terminal (ctrl+alt+t), launch ROS with the launch file teleop.launch:
    $ ros2 launch racecar_bringup teleop.launch
  6. To visualize the racecar in rviz:
    $ ros2 launch racecar_navigation rviz.launch
  7. Enable the joystick by performing an input combination below to start.
  8. Enjoy!

High-level Controller Modes

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)

Low-level Controller Modes (Arduino modes)

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published