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

ros_control code sample for a diff_drive

asked 2019-07-26 10:13:29 -0600

updated 2019-08-05 20:29:57 -0600

I am hoping your answer will serve as template for setting up diff_drive on a physical robot. Such a resource is missing, and is strongly needed.

Could you please create a small amount of code that will produce the equivalent of a hello world program for a hardware_interface that utilizes a diff_drive controller? or asked another way, could you please provide a hardware_interface implementation sample that utilizes a diff_drive controller? Please ignore advanced capabilities such as real-time capability, transmissions, limits, or any of that fancy stuff.

Why don't I do it myself? On account of a lack of documentation for ros_control and my lack of C++ skills I am not able to convert valuable examples I found into my own working code. Valuable examples being:

Could you please help by writing the simplest most minimalistic C++ code for these files:

  • src directory files:
    • robot/src/robot_hardware_interface.cpp
    • robot/src/robot_hardware_interface_node.cpp

and

  • include directory files:
    • robot/include/robot_hardware.h
    • robot/include/robot_hardware_interface.h

Code that is external to ros_control that hardware_interface node calls in read() and write(), such as converting diff_drive output (radians/second) to wheel motion, collecting feedback from the robot, as well as the URDF file is finished can be found here: https://github.com/Toronto-Robotics-c....

If someone chooses to answer this question, I will integrate the code you provide, with my code and test it out on a physical robot. By testing I mean I will use rospub to publish to the topic to which the diff drive subscribes to for geometry_msgs/Twist messages and observe the robot’s physical motion, and if needed modify the code you provided (with your permission) to verify that it works and is solid resource for the community.

Thanks.

edit retag flag offensive close merge delete

Comments

1

There might be readers here who would not have time / be in a position to write a complete hardware_interface for you, but who may be able to help you if you could describe what it is that you don't understand in the repositories / examples that you link to.

gvdhoorn gravatar image gvdhoorn  ( 2019-07-28 12:07:57 -0600 )edit

@gvdhoorn Since I am not a programmer, when I encounter complex code with no documentation (such as in this case) usually I am not able to hack my way to a working solution. I do know that the examples I mentioned are good, but they do not have a standardized structure, they have a bunch of code that I cannot distinguish as relevant to me or not, and generally without some guidance I have not been able to get very far. believe me I tried. If I begin to ask questions about what I do not understand, there will be at least 50 "noob" type questions that are not going to be very impressive. My thoughts were to get someone to finally create an answer that others like me (those who rely on simple documentation to build from) can use to implement a diff_drive controller. Such a resource can then ...(more)

BuilderMike gravatar image BuilderMike  ( 2019-08-02 20:20:04 -0600 )edit

My thoughts were to get someone to finally create an answer that others like me [..] can use to implement a diff_drive controller

A controller, or a hardware_interface? diff_drive_controller already exists, and you shouldn't need to create it for your own system.


Edit: if you're actually asking for an example hardware_interface implementation then the answer would be relative simple to give, but it would also miss quite some implementation details (specifically: how it interfaces with the underlying hw, which is the job of a hardware_interface).

If you're really asking for a controller, that would be something else.

gvdhoorn gravatar image gvdhoorn  ( 2019-08-03 06:07:58 -0600 )edit

@gvdhoornedit: I misspoke, I do not need to implement a diff_drive controller, I need help to implement the hardware_interface (as a complete sample) that utilizes a diff_drive controller. As for the underlying hw, that code is already written in the form of a library. My library needs a radians/sec input and then takes care of the corresponding wheel motion (can be found here: https://github.com/Toronto-Robotics-c...) . If someone could please provide a hardware_interface sample that utilizes a diff drive controller (including the src and include files), or provide a link to the most basic sample that would be very, very, very appreciated.

BuilderMike gravatar image BuilderMike  ( 2019-08-03 11:25:31 -0600 )edit
1

Does my ugly code help? turtlebot3_custom_hardware.h: Set for two wheels, ignore the dynamic reconfigure part. Insert the hardware specific code in read() and write(). Or could you just add your code and tell us your error?

Humpelstilzchen gravatar image Humpelstilzchen  ( 2019-08-06 00:47:55 -0600 )edit

@Humpelstilzchen what kind of hardware does your code speak to? I see that you are giving RPM targets over i2c. Is the pid handled by the controller?

wintermute gravatar image wintermute  ( 2019-11-19 18:15:10 -0600 )edit

Yes, the pid is running on an AVR microcontroller.

Humpelstilzchen gravatar image Humpelstilzchen  ( 2019-11-19 23:38:35 -0600 )edit

@Humpelstilzchen I am working on the same thing as OP. Can you help me understand a little of the code you linked to? Is the hardware_interface class running under ROS or on the Arduino which is controlling the motors? Also does your "ugly code" work well?

pitosalas gravatar image pitosalas  ( 2020-02-14 15:43:48 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2020-01-02 20:00:40 -0600

Of all the diff drive projects I was able to find, the best samples have been: https://github.com/eborghi10/my_ROS_mobile_robotand (https://github.com/husky/husky) Clearpath's Husky.

edit flag offensive delete link more
0

answered 2020-04-12 09:12:38 -0600

azerila gravatar image

updated 2020-04-12 09:14:05 -0600

this page also seems quite useful. I would appreciate if anyone else also let me/us know if there was a simple implementation, preferably without gazebo. I myself still haven't found my way in implementing the harware interface.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-07-26 10:13:29 -0600

Seen: 785 times

Last updated: Apr 12 '20