Is it possible to see a Simulink robot in Gazebo with ROS 2?

asked 2022-05-23 03:56:22 -0500

jon.aztiria gravatar image

I'm trying to perform a co-simulation in Gazebo of a robot modelled in Simulink and another in Gazebo with the FMI standard. I'm using Ubuntu 18.04 running ROS Melodic, ROS 2 Dashing and Gazebo 9.19.

I have both robot models working, I'm able to program different trajectories and visualize them in each platform. I've also exported the Simulink robot as a FMU and I'm able to simulate it successfully in ROS 2 with the fmi_adapter. However, this only returns the trajectory values (x, y and z coordinates as they are the FMU outputs) in each time step, i.e., I don't know how to visualize this in Gazebo.

I've seen the gazebo-fmi functionality to add plugins to Gazebo, but I'm not sure if it's useful for this case and how to use it.

Is there any work done in this field?

Don't hesitate to ask for clarification or more details, if necessary. I would really appreciate any help.

Jon

edit retag flag offensive close merge delete

Comments

Does this visualization need to be in Gazebo? Or will a standard RViz suffice?

ljaniec gravatar image ljaniec  ( 2022-05-23 06:54:57 -0500 )edit

No, RViz is completely valid for me. Do you have any idea of how to do it? Thanks!

jon.aztiria gravatar image jon.aztiria  ( 2022-05-23 12:31:36 -0500 )edit

This would be similar to these answers: https://answers.ros.org/question/2092...https://answers.ros.org/question/2263...https://www.theconstructsim.com/ros-q...https://answers.ros.org/question/2786... - you need to convert the trajectory values into a ROS message (e.g. Path from nav_msgs) and publish it to RViz (if this message can be visualized by RViz, of course). If you implement a solution for you, please add it in the edit of the or in the answer to the question for the future readers :)

ljaniec gravatar image ljaniec  ( 2022-05-24 01:44:30 -0500 )edit

Also, just a heads up, take this from somebody who worked with Dashing. It's not a great version of ROS2. A lot has not been ported to it and it has also reached EOL, so nobody is working to fix existing stuff either. I would not recommend anybody using a ROS2 version before Foxy (even before Dashing had reached EOL).

If you're also running ROS Melodic and there is no specific reason to use Dashing, stick to Melodic. It still has another year of support left and it works a lot better than Dashing.

Joe28965 gravatar image Joe28965  ( 2022-05-24 03:17:31 -0500 )edit

Thanks for the links @ljaniec and the consideration of ROS distribution @Joe28965. I'll try it and edit the question if I succeed. Maybe this MATLAB plugin can be useful together with gazebo-fmi package. If anyone has a detailed plan of how to do it, proposals are welcome.

jon.aztiria gravatar image jon.aztiria  ( 2022-05-24 03:21:26 -0500 )edit

There is a VM with Matlab & Simulink for control and Gazebo as simulator that is with ROS2 Dashing (e.g. https://www.mathworks.com/matlabcentr... ), maybe that's why it was used? The gazebo-fmi project has not been developed much lately, at least according to their repository history and issues on Github

ljaniec gravatar image ljaniec  ( 2022-05-24 03:40:20 -0500 )edit
1

Is this a N-dof manipulator, or a planar robot, or a mobile base, a drone, or something else?


Edit: MARA is a 6dof manipulator.

If your Simulink model only outputs Cartesian positions, that's not something that can be immediately visualised using RViz.

You'll need to convert those to joint poses using IK.

nav_msgs/Path is not meant to carry poses of manipulators.

gvdhoorn gravatar image gvdhoorn  ( 2022-05-24 03:49:11 -0500 )edit

Yes, I didn't notice that the robot model was mentioned in one of the GitHub links, sorry. Of course nav_msgs/Path is for mobile robots. Inverse kinematics to determine the joint pose of the 6 DoF manipulator from Cartesian positions seems to be essential there, it's a useful note

ljaniec gravatar image ljaniec  ( 2022-05-24 04:57:56 -0500 )edit