ros-mobile-robots / diffbot

DiffBot is an autonomous 2wd differential drive robot using ROS Noetic on a Raspberry Pi 4 B. With its SLAMTEC Lidar and the ROS Control hardware interface it's capable of navigating in an environment using the ROS Navigation stack and making use of SLAM algorithms to create maps of unknown environments.
https://ros-mobile-robots.com
BSD 3-Clause "New" or "Revised" License
275 stars 82 forks source link

Single Board Computer I2C Connection #77

Closed pkr97 closed 1 year ago

pkr97 commented 1 year ago

Hi Franz, I find it a bit confusing that the MCU is going to handle the Motor encoder and also Actuation. The MCU should be receiving commands and possibly sending sensory readings to the SBC as shown here https://ros-mobile-robots.com/fritzing/remo_architecture.svg

While going through the Hardware Interfaces section, I found that the SBC needs to communicate with the motor driver. This contradicts the figure shown here https://ros-mobile-robots.com/fritzing/remo_architecture.svg

This brings some ambiguity that how to connect all the hardware for minimal testing at the first place.

Best.....

fjp commented 1 year ago

Hi @pkr97, first let me clarify that in the docs are parts that refer to the low-level approach and some parts to the high-level approach. This is not so nice and I hope to get back more time to fix this soon. So without knowing which parts you are referring to in the docs it is a bit hard for me to give proper feedback. Anyway let's try:

I found that the SBC needs to communicate with the motor driver

Here I assume with you mean the https://github.com/ros-mobile-robots/grove_motor_driver which is the motor driver that is used for the diffbot prototype I built first when I started this project.

The write() method in the hardware interface serves currently two interfaces (which is a bit confusing):

The high-level approach that is based on the schematic shown above and is for the "old" diffbot model.

The link you posted of the new remo robot schematic is using the low-level approach. I recently explained the difference between the high and low level approaches here: https://github.com/ros-mobile-robots/diffbot/discussions/76#discussioncomment-4975667

I find it a bit confusing that the MCU is going to handle the Motor encoder and also Actuation.

The reason for not processing the encoder ticks on the SBC is that it might miss some ticks if the rate of ticks is too high. Usually a mcu is a better fit for this becasue its pins should be able to handle higher frequencies. Anyway depending on the encoders this might work as well if the encoders are directly connected to the SBC. For diffbot and remo robot, the encoders ware always connected to the mcu and then those sensor information was read via rosserial on the SBC.

As mentioned above, for diffbot, I used the approach you mention: that the SBC communicates with the (grove) motor driver and receives directly the motor commands from the ROS control hardware interface. The current approach I use for remo robot is to compute "high-level" control commands using ROS control and the diff_drive_controller (which works with a VelocityInterface) and then send those "high-level" velocity commands to the mcu where it gets converted to motor commands. Which approach to choose is personal preference I would say and both is possible.

In the remo schematic the mcu receives the high level velocity commands from the SBC via USB and then communicates with the motro driver board (FeatherWing) via i2c (yellow and white wires; the blue pcb with the four white connectors).