ros_control code sample for a diff_drive
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:
- husky robot: https://github.com/husky/husky
- ros control boiler plate: https://github.com/PickNikRobotics/ro...
- Slate robotics tutorial (which also points to the source code): https://slaterobots.com/blog/5abd8a1e...
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.
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 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)
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 ahardware_interface
).If you're really asking for a controller, that would be something else.
@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.
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 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?
Yes, the pid is running on an AVR microcontroller.
@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?