Ask Your Question

How to include motor wheel encoder ticks to ros_control hardware interface

asked 2021-06-08 15:51:18 -0500

balint.tahi gravatar image


I have an FC-03 motor wheel encoder (infrared speed sensor module with the LM393 comparator) which I would like to use with my differential drive robot.

I can get the ticks from the sensor, the encoder disc has 20 ticks / rotation, which seems to work fine.


1) How to include this into the hardware interface for the ros_control? The encoder don't know the direction of the movement, it can only provide the pulses / ticks, so basically it will be an incremental number.

2) Do I need to calculate the odom, or it will be done automatically by ros_control?

3) Is there any example?

Any help would be greatly appreciated!


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-06-09 02:47:17 -0500

Humpelstilzchen gravatar image

updated 2021-06-09 02:48:27 -0500

1) Had the same problem once, my solution was to compute the direction from the given direction. So e.g. if I send the command to the motor to drive counter-clockwise I had it counting the ticks upwards, for clockwise downwards.

2) ros_control can do that with diff_drive_controller

3) This is answered here: ros_control code sample for a diff_drive

edit flag offensive delete link more


Thanks! I am calculating the direction based on the last velocity command to the wheel. Not a perfect solution, but better than nothing.

I used the my_ROS_mobile_robot as an example, it helped me in some steps, but made me some headache in others ... (pos and vel calculation in the read() function). Now it looks ok.

balint.tahi gravatar image balint.tahi  ( 2021-06-14 11:17:08 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2021-06-08 15:51:18 -0500

Seen: 19 times

Last updated: Jun 09