gazebosim / gz-sim

Open source robotics simulator. The latest version of Gazebo.
https://gazebosim.org
Apache License 2.0
621 stars 251 forks source link

Make child model and link configurable in DetachableJoint System #2362

Open jasmeet0915 opened 3 months ago

jasmeet0915 commented 3 months ago

Desired behavior

Currently, the detachable joint system allows you to attach or detach a joint between a parent and a child model by publishing an Empty message on the respective topics. For this to work we have to specify the child model and link name in the SDF of the plugin. However, while simulating some real world operations I found the need of allowing my simulated robot to be able to create 'detachable joints' with different child models at different times.

This is similar functionality like the gazebo_ros_link_attacher plugin which provided a service to attach and detach joints between any two models as per the request.

Implementation suggestion

Currently the detachable_joint system assigns the modelEntity and childLinkEntity in the PreUpdate() function of the plugin using the childModelName and childLinkName members that are set in the Configure() function from the values given in the SDF. So I think instead of having a separate attach / detach topic with Empty msg type, it should be possible to advertise a service with a custom message type of detachable joint msg composed of string fields that allows you to set the child_model_name, child_link_name and operation (attach or detach). In the callback of the service, we could set the requested values for the required data members. The detachable_joint service could also be added to the ros_gz_interfaces package to allow bridging of this service.

I would be happy to create a pull request implementing the changes mentioned if they sound right!