Skip to content

AARC-lab/can_to_ros

Repository files navigation

can_to_ros

can_to_ros is a ROS package that provide a real-time and offline decoding of CAN bus messages. It is also integrated with libpanda to send control commands to Toyota RAV4.

Note to this repos: This is a fork of the original repo https://github.com/jmscslgroup/can_to_ros and serves to playbag CAN data file as on ROS network in ros-realtime and saves as a bag file. This is intended for testing any controller algorithm with software-in-the-loop simulation but with the real data.

Software Requirements and Dependencies

  • Ubuntu 18.04/20.04 AMD64 or Ubuntu18.04/20.04 ARM
  • ROS melodic or ROS noetic
  • libpanda (must be installed in /opt directory)

Playing back CAN data on ROS network

  1. Clone this repository to src directory of your catkin workspace ~/catkin_ws/.

    cd ~/catkin_ws/src
    git clone https://github.com/AARC-lab/can_to_ros
    cd can_to_ros/scripts
    
  2. Clone https://github.com/jmscslgroup/strym your home directory

cd ~
git clone https://github.com/jmscslgroup/strym

3: Edit the vin file in scripts folder of can_to_ros, and enter the VIN number of the vehicle whose CAN bus data you have.

cd ~/catkin_ws/src/can_to_ros/scripts
gedit vin

enter the appropriate VIN.

4: Run regenerateCanToRos.sh as

./regenerateCanToRos.sh
  1. Recompile your catkin workspace
cd ~/catkin_ws
catkin_make
  1. Execute the launch file as:
roslaunch can_to_ros piping.launch publish_csv_args:="-c 2021_04_08/2021-04-08-12-26-57_2T3Y1RFV8KC014025_CAN_Messages.csv -g 2021-04-08-12-26-57_2T3Y1RFV8KC014025_GPS_Messages.csv" bag_name:=2021-04-08-12-26-57_2T3Y1RFV8KC014025_BAG_Messages.bag

The above command plays back 2021-04-08-12-26-57_2T3Y1RFV8KC014025_CAN_Messages.csv on the ROS network and is suitable for testing any vehicle application that may consume live vehicle data, and simultaneously saves the data as a rosbag file.




Launch File Descriptions:

vehicle_control.launch

This is automatically installed in robot_upstart with libpanda's scripts/installCanToRos.sh script

Invokes the following:

  1. vehicle_interface - Main interface for libpanda's ToyotHandler for vehicle control
  2. publishCommands - Maintains a regular 100Hz publish rate from /cmd_accel_safe to /car/cruise/accel_input
  3. node_status.py - Regulary publishes a 0 to /cmd_accel to maintain libpanda's command heartbeat if other commands are not sent
  4. launch/safety_checks.launch
  • cut_in_disengager - Ensures that cars cutting in ahead do no coincide with large deceleration commands by disengaging the cruise controller.
  • cruise_start_safety_check - Ensures that acceleration commands start within safe bounds and that a lead vehicle is seen on engage requests (otherwise a disengage is invoked)
  1. topic_check.py - Checks publish rate of /car/libpanda/controls_allowed to dispaly status on Blinkt kit

Expected interface topics:

/cmd_accel - std_msgs/Float64 - This is where control commands should be sent. cut_in_disengager will ensure convert this to /cmd_accel_safe as needed, then publishCommands will convert /cmd_accel_safe to /car/cruise/accel_input /car/can/raw - std_msgs/String - Reports CAN data. Use the node subs_fs.cpp to interpret these into car sensing data

piping.launch

This launch file allows you to pipe in replayed CAN and/or GPS data stored in CSV files, as if they are being read directly from the car in real time. Make sure that the generated subs.cpp node matches the vehicle type of the CSV file you are playing back data from. Caviat: the playback timing is not perfect in all cases but still very useful.

Usage:

roslaunch can_to_ros piping.launch publish_csv_args:= "-c {/FILEPATH/DATE_VIN_CAN_Messages.csv} -g {/FILEPATH/DATE_VIN_GPS_Messages.csv}" bag_name:="my_bagfile"

Uses:

  1. Creating new bagfiles for data. E.g. you've added new nodes and want to do software-in-the-loop testing.
  2. Playback for Ros2Ascii visualizations. Example snippet here for a Honda Pilot.

Node Descriptions:

vehicle_interface.cpp

This ROS node interfaces libpanda's ToyotaHandler

Publishers:

  1. /car/can/raw - std_msgs/String - This publishes CAN data of interest where the can_to_ros node named subs_fs.cpp can interpret values
  2. /car/panda/gas_interceptor_detected - std_msgs/Bool - Reported by the Panda is their gas interceptor hardware is detected
  3. /car/panda/controls_allowed - std_msgs/Bool - Reported by the comma.ai panda. This is not event-based from the Panda, but is regularly checked at 2 Hz to reset the Panda's heartbeat
  4. /car/libpanda/controls_allowed - std_msgs/Bool - Reported by logic within libpanda. This is event based from libpanda using CAN messages. When no events occur, this regularly published at 1 Hz which can be used to assess libpanda's control command health

Subscribers:

  1. /car/cruise/accel_input - std_msgs/Float64 - This is for acceleration commands to be sent to the car's cruise controller (priorly known as /commands)
  2. /car/hud/mini_car_enable - std_msgs/Bool - When true, this will display a mini-vehicle on the car's HUD which cruise control is on and engaged
  3. /car/hud/cruise_cancel_request - std_msgs/Bool - When true published, the cruise controller will disengage and notify the driver with an audible chime

Installation


  1. Create a ROS Workspace
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
  1. Clone the repo.
$ cd ~/catkin_ws/src/
$ git clone https://github.com/AARC-lab/can_to_ros.git

Note: make sure to install libpanda before running catkin_make.

  1. Build the WS
$ cd ~/catkin_ws
$ catkin_make
  1. Source your enviroment:
$source ~/catkin_ws/devel/setup.bash

Tests:


The following tests were performed on a Toyota RAV4

1-Sending Acceleration Commands to RAV4

We created a set of slides (Step Input Commands Test) that have the steps needed to send acceleration commands to a Toyota RAV4.

2-Runnig Cruise Control Test

The goad of this test is to replicate the cruise control functionality with a PID controller. Steps to run the test are here.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages