/gazebo_ros_link_attacher-fork

Attach two Gazebo models with a virtual joint in a generalized grasp hack

Primary LanguagePython

Gazebo ROS Link Attacher

This library is used to attach two Gazebo models with a virtual joint in a generalized grasp hack.

Build

mkdir -p gazebo_link_attacher_ws/src
cd gazebo_link_attacher_ws/src
catkin_init_workspace
git clone https://github.com/pal-robotics/gazebo_ros_link_attacher.git
cd ..
catkin_make
source devel/setup.bash

Launch

roslaunch gazebo_ros_link_attacher test_attacher.launch

Empty world with the plugin libgazebo_ros_link_attacher.so loaded (in the worlds folder).

Which provides the /link_attacher_node/attach service to specify two models and their links to be attached.

And /link_attacher_node/detach service to specify two models and their links to be detached.

gazebo screenshot

Run demo

In another shell, be sure to do source devel/setup.bash of your workspace.

rosrun gazebo_ros_link_attacher spawn.py

Three cubes will be spawned.

rosrun gazebo_ros_link_attacher attach.py

The cubes will be attached all between themselves as (1,2), (2,3), (3,1). You can move them with the GUI and you'll see they will move together.

rosrun gazebo_ros_link_attacher detach.py

The cubes will be detached and you can move them separately again.

You can also spawn items with the GUI and run a rosservice call:

rosservice call /link_attacher_node/attach "model_name_1: 'unit_box_1'
link_name_1: 'link'
model_name_2: 'unit_sphere_1'
link_name_2: 'link'"

And same thing to detach:

rosservice call /link_attacher_node/detach "model_name_1: 'unit_box_1'
link_name_1: 'link'
model_name_2: 'unit_sphere_1'
link_name_2: 'link'"

20220115: YUHANG-Ma update.
original version: https://github.com/pal-robotics/gazebo_ros_link_attacher In the history version, when attach and detach a static target, gazebo experienced an anomaly that prevented the robot from moving. In this version, When the macro definition DONOT_ATTACH_STATIC_MODEL is set, judge the target attribute. If the target is static, it will not be executed attach!

#define DONOT_ATTACH_STATIC_MODEL 1