Matlab and ROS integration

2 views (last 30 days)
Imran
Imran on 7 Oct 2023
Edited: Imran on 21 Oct 2023
I have created matlab code where robot does exploration, the map is binary occupancy map (20x20m). Now I am trying to integrate it with ROS2
I have few questions
1. How can I linearly transform map, so that matlab map dimensions matches the gazebo map for turtlebot3.
2. does turtlebot3 requires cmd_vel for its rotation or movement or we can make it work with /position as well.
subscriber publisher code has been made where it recives /positions from matlab. It has been checked with
ros2 topic echo /position.
Though these things are working, but my tb3 is not moving.

Accepted Answer

Yatharth
Yatharth on 16 Oct 2023
Hi Imran,
I understand that you are trying to integrate MATLAB with ROS2 and want to know if you can linearly transform your map. You are also trying to resolve the issue of your Thunderbot3 not moving.
1. Linear Transformation of the Map:
  • First, ensure that the dimensions of your MATLAB map match the dimensions of the Gazebo map for the Turtlebot3. If they don't match, you'll need to rescale your MATLAB map to match the size of the Turtlebot3's map.
  • You can use the "imresize" function in MATLAB to resize your map. For example, if your MATLAB map is 20x20m and the Turtlebot3's map is 10x10m, you can resize your MATLAB map to match the Turtlebot3's map size using:
resizedMap = imresize(originalMap, [10 10]);
2. Turtlebot3 Movement:
I hope this helps.
  3 Comments
Yatharth
Yatharth on 18 Oct 2023
The "geometry_msgs/Twist" message is the correct message type to control the Turtlebot3's movement. The "geometry_msgs/Twist" message contains linear and angular velocities, which are required to control the robot's motion.
On the other hand, the "geometry_msgs/Point" message only contains x, y, and z coordinates, which are not sufficient to control the Turtlebot3's movement directly. That's why you are seeing all zero values when you check the "/cmd_vel" topic.
To control the Turtlebot3 using your MATLAB code, you need to modify it to publish "geometry_msgs/Twist "messages instead of "geometry_msgs/Point" messages. The "geometry_msgs/Twist" message should contain appropriate linear and angular velocities for the desired movement.
You can refer to the link below for more help.
Imran
Imran on 20 Oct 2023
Edited: Imran on 21 Oct 2023
Hi
thats really helpful. since I am new in ROS, and I do understand that my x,y are robot position not linear angular velocities. Can you show me direction how can I change my points to velocities? cause I followed the link you shared still when I check my linear & angular velocities are zero. "ros2 topic echo /cmd_vel"

Sign in to comment.

More Answers (0)

Categories

Find more on Specialized Messages in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!