Recently i started my own robot project to learn ROS, using Arduino. So far i just have a single Arduino + L289n dual h-bridge motor controller to power 2 DC motors
The initial setup of my project is based on the Husky project, so i have a base node containing a hardware_interface::RobotHW class that communicates with the Arduino. Using the teleop_twist_keyboard i'm able to move my robot. Currently this is done using a custom message, where the RobotHW is the advertiser and the Arduino the subscriber. But just driving the motors is far from enough. I'm using powerfull 24V DC motors salvaged from broken printers and big (heavy) wheels from an old RC car. Currently i'm running the motors are 12v, which seem to be enough to get the robot rolling, but it takes time to get up to speed cause of the big heavy wheels and they keep spinning once the wheel speed is set to 0.
To apply brake force to the wheels i need to reverse the motor power till the wheels stopped, so i got myself some motor encoders to measure the speed of the wheels. According to the hardware interface documentation and code i been checking to learn how it works, i need to read from the hardware, update the controller manager, then write to the hardware. So using ROS message system doesn't seem the correct way.
Been looking into using rosserial for c++ and using the Serial communication in the Arduino firmware instead of message advertisers/subscribers, but this require writing some custom protocol for messages between the hardware and the hardware interface node.
So before continuing writing a custom serial comm protocol, i wanted to know if this is the correct way to go, or if i should just use advertisers/subscribers to send custom messages between the hardware/ros node?
Full code of my project in the current state of using messages can be found here: https://github.com/DeborggraeveR/ampru
the ampru_base package, contains both the firmware and the hardware interface node.
Post score: 0
Comment by Soleman on 2022-02-07:
hey @RandyD. I saw your work its very impressive. I am very new to ros. I have same configuration like your as 2 dc motos with encoders, 1 arduino mega, 1 IMU sensor, 1 intel realsense D415. Currently I am facing a problem that how to set odometry using my dc motors and arduino. I am very new the brief guidelines will be highly appreciated. Thank you.