ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Communication with microcontroller via CAN

asked 2012-10-19 09:14:35 -0500

platzhirsch gravatar image

updated 2014-01-28 17:14:00 -0500

ngrennan gravatar image

Hi, our team want to develop an autonomous car on the basis of a RC-Car. As framework we want to use ROS. Unfortunately none of us has any experiences with ROS.

The microcontroller that interfaces with the hardware of the car shall communicate with an embedded PC via CAN. The embedded PC has a CAN interface. I have found the can_communication stack, which contains a package called can_msgs. If I have understood right this package provides only a CAN library for ROS and is not executable. Is there something like a ready CAN-node? Unless how can I realize a CAN communication? Currently I'm the only person which works on the software. Unfortunately I have not many experiences in this field. Hence I would be very grateful for any help.

edit retag flag offensive close merge delete


I've never used it, but I know care-o-bot uses CAN and has the cob_generic_can package.

thebyohazard gravatar image thebyohazard  ( 2012-10-19 10:37:29 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-10-20 19:41:15 -0500

dbworth gravatar image

updated 2012-10-20 19:47:26 -0500

Expanding from dornhege, I would first write some Python/C++ code that communicates with the microcontroller. You could use the CAN drivers that are included with Linux, which are called Socket-CAN. There should be plenty of example code using that, on the internet. Once you can send/receive CAN messages, you then need to design the commands for a software driver for your car, eg. turnLeft() driveForward() which take a control command and send a CAN message.

Once you have your driver for the car working, you can incorporate it into ROS. You should read all the tutorials and write some publisher and subscriber nodes. Then you need to implement your higher level commands as a ROS subscriber, eg. if a tele-operation node publishes a Float64 message on the /drive_forward_command topic, the subscriber inside your rc_car_driver node gets a callback and processes the contents of the ROS message, sending the velocity value to the driveForward() function.

This post is useful:

It could be a lot of work to implement this when your microcontroller and the embedded PC are sitting next to each other. Another possibility is: It sounds like it's pretty easy to send rosserial messages directly to an arduino:

edit flag offensive delete link more

answered 2012-10-19 10:12:45 -0500

dornhege gravatar image

Usually, this is part of the driver itself (at least for our implementations) and the ROS abstraction layer is higher, e.g., things like odometry or velocity commands.

edit flag offensive delete link more

Question Tools



Asked: 2012-10-19 09:14:35 -0500

Seen: 3,654 times

Last updated: Oct 22 '12