CommonplaceRobotics / iRC_ROS

ROS2 packages for the igus Robot Control
Apache License 2.0
15 stars 7 forks source link

Add Gazebo support #23

Open cpr-fer opened 1 year ago

cpr-fer commented 1 year ago

It would be practical to have fake hardware support for testing and simulating. Is ros2_control fake hardware the best approach for this? Also how hard is this to integrate into a simulation framework such as gazebo?

cpr-fer commented 1 year ago

Reopening this, as the issue only addressed ros2_control stuff, not gazebo itself.

First next step is likely to add use_sim_time parameters to all relevant nodes and settings

cpr-fer commented 1 year ago

Regarding the laser scanners on the mobile platform and gazebo the Nav2 wiki has a nice tutorial: https://navigation.ros.org/setup_guides/sensors/setup_sensors.html#simulating-sensors-using-gazebo

JHeuverRiwo commented 1 year ago

hey,

We have a Igus set up in Gazebo, let me know if (and perhaps how) you want to integrate the code into iRC_ROS!

cpr-fer commented 1 year ago

Hey @JHeuverRiwo sorry for the late reply. It really great that you got it running with Gazebo!

I myself have no experience with gazebo, so I am unsure how this is normally done in ROS packages. In general I would definitely like to have this either integrated or in a separate repo that is linked somewhere in the readme.

Let me research a bit how other ROS2 robot packages do the gazebo integration and if there's any legal stuff that might cause problems when integrating it into this repo and I'll get back to you

JHeuverRiwo commented 1 year ago

Hey @cpr-fer,

Great; let me know if you run into anything I could help with. We used the UR ignition simulate package as reference if that's any help (https://github.com/UniversalRobots/Universal_Robots_ROS2_Ignition_Simulation/tree/ros2). We're running Gazebo Fortress right now along with ign_ros2_control.

JHeuverRiwo commented 1 year ago

Hey,

I noticed that the meshes are not always properly importing into Gazebo. I read on https://github.com/robotology/idyntree/issues/291 that the 'package' tag in the uri may not be parsed correctly by external libraries such as gazebo. Concretely, switching from filename="package://irc_ros_description/MESH_DIR to filename="file://$(find irc_ros_description)/MESH_DIR helps resolve this issue for me.

cpr-fer commented 1 year ago

Hey @JHeuverRiwo

I looked a bit into it:

I'll test your proposed changes for the meshes sometime this week and merge them if it works. Do you have a fork with your current Gazebo code that you would be willing to share? Otherwise I would start a new branch here and try to use the same package as a reference that you used.

In case there is anything confidential in the code that you would prefer to discuss over email feel free to mail me at fer [at] cpr-robots.com

JHeuverRiwo commented 1 year ago

Hey @cpr-fer,

That sounds good! The package we are using right now is separated from your driver, and it contains a few things specific to our setup, so I would need to do a little bit of work (really nothing too big) to make it ready for integration. I can probably start working on that somewhere end of next week.

I think how I would integrate it, is by moving our code to a separate moveit config package contained in your driver (called something like 'irc_ros_sim_moveit_config'); this way you could start the rebel with the right controllers and other configuration files or import it using the moveit configs builder into launch files. I think it's probably easiest if I fork your repo and submit a pull request when it is ready for you, if that also works for you. Let me know what you think!

In case something comes up from our side I will also let you know.

cpr-fer commented 1 year ago

Hi @JHeuverRiwo

That sounds like a great way to move forward with this! In the meantime I started to familiarize myself a bit with gazebo and the UR package you linked above, so that I'll be able to understand your future pull requests :)

Thanks a lot, I am really looking forward to this

robin-mueller commented 1 year ago

Hey,

are there any updates on how to simulate the igus ReBeL 6DOF with Gazebo? Moreover, is there any simulation support at all currently? Neither the option mock_hardware nor gazebo for the launch argument hardware_protocol manages to start both the controller and the joint state broadcaster successfully. That is, when I'm trying to launch using ros2 launch irc_ros_bringup rebel.launch.py or ros2 launch irc_ros_moveit_config rebel.launch.py.

I did not quite understand what kind of support was added with #50.

Thanks for any help on that :)

cpr-fer commented 1 year ago

Hi @robin-mueller

are there any updates on how to simulate the igus ReBeL 6DOF with Gazebo?

I don't know the current state of what @JHeuverRiwo was planning, I have not found the time yet to work on it myself :/

Moreover, is there any simulation support at all currently? Neither the option mock_hardware nor gazebo for the launch argument hardware_protocol manages to start both the controller and the joint state broadcaster successfully. That is, when I'm trying to launch using ros2 launch irc_ros_bringup rebel.launch.py or ros2 launch irc_ros_moveit_config rebel.launch.py.

Well I would not really call it simulation, but the mock_hardware option launches the two controllers successfully for me. Can you post your launch log here?

$ ros2 launch irc_ros_bringup rebel.launch.py hardware_protocol:=mock_hardware

# Different terminal
$ ros2 control list_controllers
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active    
joint_trajectory_controller[joint_trajectory_controller/JointTrajectoryController] active

The gazebo launch option was added for future use, as of now it does not do anything yet

robin-mueller commented 1 year ago

Hey @cpr-fer,

my log is as follows

$ ros2 launch irc_ros_bringup rebel.launch.py hardware_protocol:=mock_hardware

[INFO] [launch]: All log files can be found below /home/robin/.ros/log/2023-08-17-09-38-28-181944-hp-envy-x360-3224
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [3227]
[INFO] [joint_state_publisher-2]: process started with pid [3229]
[INFO] [ros2_control_node-3]: process started with pid [3231]
[INFO] [spawner-4]: process started with pid [3233]
[INFO] [spawner-5]: process started with pid [3235]
[INFO] [rviz2-6]: process started with pid [3237]
[ros2_control_node-3] [INFO] [1692257910.131691726] [resource_manager]: Loading hardware 'igus_rebel_6dof' 
[ros2_control_node-3] [INFO] [1692257910.137745809] [resource_manager]: Initialize hardware 'igus_rebel_6dof' 
[ros2_control_node-3] [WARN] [1692257910.138009773] [mock_generic_system]: Parsing of optional initial interface values failed or uses a deprecated format. Add initial values for every state interface in the ros2_control.xacro. For example: 
[ros2_control_node-3] <state_interface name="velocity"> 
[ros2_control_node-3]   <param name="initial_value">0.0</param> 
[ros2_control_node-3] </state_interface>
[ros2_control_node-3] [INFO] [1692257910.138055560] [resource_manager]: Successful initialization of hardware 'igus_rebel_6dof'
[ros2_control_node-3] [INFO] [1692257910.138547930] [resource_manager]: 'configure' hardware 'igus_rebel_6dof' 
[ros2_control_node-3] [INFO] [1692257910.138597615] [resource_manager]: Successful 'configure' of hardware 'igus_rebel_6dof'
[ros2_control_node-3] [INFO] [1692257910.138631860] [resource_manager]: 'activate' hardware 'igus_rebel_6dof' 
[ros2_control_node-3] [INFO] [1692257910.138649454] [resource_manager]: Successful 'activate' of hardware 'igus_rebel_6dof'
[ros2_control_node-3] [INFO] [1692257910.187104220] [controller_manager]: update rate is 100 Hz
[ros2_control_node-3] [INFO] [1692257910.187710804] [controller_manager]: RT kernel is recommended for better performance
[robot_state_publisher-1] [INFO] [1692257911.766727066] [robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1692257911.767088727] [robot_state_publisher]: got segment flange
[robot_state_publisher-1] [INFO] [1692257911.767117111] [robot_state_publisher]: got segment link_1
[robot_state_publisher-1] [INFO] [1692257911.767164772] [robot_state_publisher]: got segment link_2
[robot_state_publisher-1] [INFO] [1692257911.767179280] [robot_state_publisher]: got segment link_5
[robot_state_publisher-1] [INFO] [1692257911.767225638] [robot_state_publisher]: got segment link_6
[robot_state_publisher-1] [INFO] [1692257911.767236058] [robot_state_publisher]: got segment link_7
[robot_state_publisher-1] [INFO] [1692257911.767244785] [robot_state_publisher]: got segment link_8
[robot_state_publisher-1] [INFO] [1692257911.767253712] [robot_state_publisher]: got segment tcp
[robot_state_publisher-1] [INFO] [1692257911.767298838] [robot_state_publisher]: got segment tool0
[robot_state_publisher-1] [INFO] [1692257911.767308657] [robot_state_publisher]: got segment world
[joint_state_publisher-2] [INFO] [1692257918.523636958] [joint_state_publisher]: Waiting for robot_description to be published on the robot_description topic...
[ros2_control_node-3] [INFO] [1692257920.494629346] [controller_manager]: Loading controller 'joint_state_broadcaster'
[ros2_control_node-3] [ERROR] [1692257920.494826512] [controller_manager]: Loader for controller 'joint_state_broadcaster' (type 'joint_state_broadcaster/JointStateBroadcaster') not found.
[ros2_control_node-3] [INFO] [1692257920.494858453] [controller_manager]: Available classes:
[ros2_control_node-3] [INFO] [1692257920.494876107] [controller_manager]:   controller_manager/test_controller
[ros2_control_node-3] [INFO] [1692257920.494892218] [controller_manager]:   controller_manager/test_controller_failed_init
[ros2_control_node-3] [INFO] [1692257920.494906335] [controller_manager]:   controller_manager/test_controller_with_interfaces
[ros2_control_node-3] [INFO] [1692257920.494919660] [controller_manager]:   irc_ros_controllers/DIOController
[ros2_control_node-3] [INFO] [1692257920.494932485] [controller_manager]:   irc_ros_controllers/DashboardController
[ros2_control_node-3] [INFO] [1692257920.494945289] [controller_manager]:   irc_ros_controllers/EcbpmiController
[ros2_control_node-3] [INFO] [1692257920.494959066] [controller_manager]:   controller_manager/test_chainable_controller
[spawner-4] [FATAL] [1692257920.557725544] [spawner_joint_state_broadcaster]: Failed loading controller joint_state_broadcaster
[ros2_control_node-3] [INFO] [1692257921.123015758] [controller_manager]: Loading controller 'joint_trajectory_controller'
[ros2_control_node-3] [ERROR] [1692257921.123188337] [controller_manager]: Loader for controller 'joint_trajectory_controller' (type 'joint_trajectory_controller/JointTrajectoryController') not found.
[ros2_control_node-3] [INFO] [1692257921.123214888] [controller_manager]: Available classes:
[ros2_control_node-3] [INFO] [1692257921.123245035] [controller_manager]:   controller_manager/test_controller
[ros2_control_node-3] [INFO] [1692257921.123262228] [controller_manager]:   controller_manager/test_controller_failed_init
[ros2_control_node-3] [INFO] [1692257921.123278038] [controller_manager]:   controller_manager/test_controller_with_interfaces
[ros2_control_node-3] [INFO] [1692257921.123292486] [controller_manager]:   irc_ros_controllers/DIOController
[ros2_control_node-3] [INFO] [1692257921.123306673] [controller_manager]:   irc_ros_controllers/DashboardController
[ros2_control_node-3] [INFO] [1692257921.123320690] [controller_manager]:   irc_ros_controllers/EcbpmiController
[ros2_control_node-3] [INFO] [1692257921.123336791] [controller_manager]:   controller_manager/test_chainable_controller
[spawner-5] [FATAL] [1692257921.203524465] [spawner_joint_trajectory_controller]: Failed loading controller joint_trajectory_controller
[ERROR] [spawner-5]: process has died [pid 3235, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner joint_trajectory_controller -c /controller_manager --ros-args -r __ns:=/'].
[ERROR] [spawner-4]: process has died [pid 3233, exit code 1, cmd '/opt/ros/humble/lib/controller_manager/spawner joint_state_broadcaster -c /controller_manager --ros-args -r __ns:=/'].
cpr-fer commented 1 year ago

Hi @robin-mueller

I checked your log and am 99% certain that it is another missing entry in the package.xml file. Can you add

  <exec_depend>joint_state_broadcaster</exec_depend>
  <exec_depend>joint_state_publisher</exec_depend>
  <exec_depend>joint_trajectory_controller</exec_depend>

to the bringup package xml file?

robin-mueller commented 1 year ago

Yes, so adding the above to the package.xml file results in two dependencies showing when executing rosdep check --from-paths src/iRC_ROS/ -i

System dependencies have not been satisfied:
apt     ros-humble-joint-state-broadcaster
apt     ros-humble-joint-trajectory-controller

So this repo is also dependent on ros2_controllers.

I resolved the issue by installing the missing packages with sudo apt install ros-humble-ros2-controllers.

cpr-fer commented 1 year ago

Perfect, thank you! I added the changes to the package.xml now as well