[Closed] How to control the ROSbot 2R motor's voltages directly

Hi all,
I want to control the Rosbot 2R motor’s directly. I mean, I want to have access to encoder’s data using a topic like /encoders and publish motor voltages to another topic like /motor_voltages.

How can I do that?

Hello @Ramin_Esmzad,

What you are asking for cannot be done easily. You would have to modify the repository GitHub - husarion/rosbot_ros2_firmware: Micro-ROS powered firmware for STM32F4 microcontroller in ROSbot 2.

However, if you do not want to use our controller, you can only run the firmware using microros (do not run the rosbot container) and use the topics: /_motors_cmd and /_motors_response/

You can test this by executing the command:

  1. Running microros.
    docker compose up microros

  2. Sending.

ros2 topic pub /_motors_cmd std_msgs/msg/Float32MultiArray "layout:
  dim: []
  data_offset: 0
data: [2.0, 0.0, 0.5, -1.0]"

(data order RR, RL, FR, FL)

  1. Reading:
    ros2 topic echo /_motors_response

Regards

1 Like

Hi @RafalGorecki ,

Thank you for your response.

  1. Could you give me more detail on how to change the firmware and which file is good to start to dive into?
  2. Is /_motors_cmd the velocity command?
  3. What is /_motors_response? Is it encoders output?

Best,

Hello @Ramin_Esmzad,

  1. To make changes, you need to rework
    repository GitHub - husarion/rosbot_ros2_firmware: Micro-ROS powered firmware for STM32F4 microcontroller in ROSbot 2. Next, you need to generate and upload the binary. The readme contains instructions on how to generate the binary. You can upload it using the stm32flasher tool. You can also use the script https://github.com/husarion/rosbot_ros/blob/humble/rosbot_utils/rosbot_utils/flash-firmware.py.
  2. /_motors_cmd is an array of wheel speeds in rad/s
  3. /_motors_response is positions in rad and speed in rad/s calculated from the encoders

Regards

1 Like

Hi @RafalGorecki ,
I appreciate your help. Your response was so helpful.

Do you have any dynamical model of the Rosvot 2R robot? or any 4-wheel mobile robot?

Best,
Ramin

Hi @Ramin_Esmzad,
Unfortunately, I can’t help you in this matter.

Regards

1 Like

Releated: Rosbot 2R motor specification - #2 by RafalGorecki