Ask Your Question
1

Communication with microcontroller via CAN

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

platzhirsch gravatar image

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

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

Comments

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

tbh gravatar imagetbh ( 2012-10-19 10:37:29 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

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

dbworth gravatar image

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

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: http://answers.ros.org/question/11691/how-to-communicate-the-hardware-to-a-realtime-controller/

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: http://www.ros.org/wiki/rosserial It sounds like it's pretty easy to send rosserial messages directly to an arduino: http://answers.ros.org/question/12464/splitting-work-between-ros-and-a-custom-motor-controller-board/

edit flag offensive delete link more
1

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 2,079 times

Last updated: Oct 22 '12