Namespacing hardware_interface/PositionJointInterface for multiple robots in Gazebo
I am trying to simulate three Universal Robot arms in Gazebo. I am using the official repo. I was able to spawn all the robots in Gazebo but the only the last robot(linked in the URDF) actually can move. After digging out for the problem, I noticed hardware_interface/PositionJointInterface
is not namespaced properly. So that is the reason only the robot which is linked at the end can move. I verified by changing the position of relvant joints in the URDF.
To create the issue following steps can be followed:
mkdir -p test_ws/src && cd test_ws/src
git clone https://github.com/ros-industrial/universal_robot/
catkin_create_pkg test_urdf
# Extract test_urdf.zip(attached to this post) to test_urdf package just created.
cd ..
catkin_make
source devel/setup.bash
roslaunch test_urdf ur_gazebo.launch
# In another terminal
rosrun rqt_joint_trajectory_controller rqt_joint_trajectory_controller
Currently after executing the above mentioned launch file a gazebo world with three arms will be simulated. Now only left arm can be moved as it is linked at the the end in test_urdf/urdf/test.urdf.xacro
. If another arm is taken to the last in the same URDF than that can be moved only.
The problem actually lies in defining the respective hardware_interface/PositionJointInterface
which currently is the same for everyone. As can be seen in test_urdf/urdf/arms/
right, center or left arm.
Is there any way that hardware_interface/PositionJointInterface
can be taken into namespaces respectively in xacro
files?
Asked by Tahir M. on 2020-08-05 03:25:06 UTC
Answers
You can use the <robotNamespace>
tag for the ros_control plugin in the .xacro (also have a look at the Gazebo Tutorial). The UR description loads the plugin in the common.gazebo.xacro file.
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/MYROBOT</robotNamespace>
</plugin>
</gazebo>
Your controllers also need to account for the namespace afterwards. If found that using namespaces in the launch files using ns=
is a simple way to add the namespace. For the UR you will probably have to change it in the controller_utils.launch of the ur_gazebo package:
<rosparam file="$(find ur_gazebo)/controller/joint_state_controller.yaml" command="load" ns="/MYROBOT" />
<node name="joint_state_controller_spawner" pkg="controller_manager" type="controller_manager" args="spawn joint_state_controller" respawn="false" output="screen" ns="/MYROBOT"/>
For multiple robots I'd suggest using arg
instead of the hardcoded /MYROBOT
.
Asked by Tuebel on 2021-06-02 01:48:34 UTC
Comments
@gvdhoorn can you please say something for this issue?
Asked by Tahir M. on 2020-08-05 04:46:06 UTC