CAN Interface package provides integration between ROS and CAN bus.
can_node
is a python script which implements bidirectional translation between ROS Topics and CAN frames.
/drive
(ackermann_msgs/AckermannDriveStamped) This topic contains speed and steering angle data. The data is used to control vehicle.
/speed
(std_msgs/Float64)[10 Hz] Speed feedback received from can bus./distance
(std_msgs/Float64)[10 Hz] Distance feedback received from can bus./steering_angle
(std_msgs/Float64)[10 Hz] Steering angle feedback received from can bus.
Install required software by typing following command:
rosdep install can_interface
You have to install newest verion of python-can
manually:
pip install python-can
You can test functionality of this package by using virtual interface. First you need to bring it up by using following commands:
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
Then you can run python node:
rosrun can_interface can_node
You can generate CAN frame by using following command:
cansend vcan0 31d#11223344AABBCCDD
Number before hashtag is frame id. Number after hashtag is frame data.
You can print all data that is being received by a CAN interface by using following command:
candump vcan0
Using rqt package is good option to sending and receiving ROS topics.
canplayer vcan0=slcan0 -v -I name.log
Execute following script to configure static port:
./port_setup.sh
Plug in USB device and then:
ls /dev
sudo slcand -o -s8 -t hw -S 1000000 /dev/ttyACM8
sudo ip link set up slcan0
Alternatively, with linux static port setup you can execute following script:
./slcan.sh
candump slcan0,B1D:F00
cansniffer slcan0
If you run into error sendto: No buffer space available
just type:
sudo ifconfig slcan0 txqueuelen 1000