frankaemika / franka_ros

ROS integration for Franka research robots
https://frankaemika.github.io
Apache License 2.0
353 stars 308 forks source link

franka_gazebo dual-arm launch error #174

Closed YaoweiFan closed 2 years ago

YaoweiFan commented 2 years ago

I want to use two panda arms in gazebo, so I write dual_arm.launch file referencing your guide. But I found that sometimes one panda arm moves strangely while the other is ok. This happens occasionally but really confuses me.

Could you give me a hint where I am doing something wrong?

gollth commented 2 years ago

Hello @YaoweiFan,

this is related to the pausing & unpausing of Gazebo. Your panda_2 gets the $(arg paused) passed along. When you check the panda.launch file, you see that this bool basically passes the -unpause flag to the model spawner, which unpauses the simulation as soon as the model is loaded:

https://github.com/frankaemika/franka_ros/blob/1922fc9d24e37b2a8226c522e736eaa9a65d66ca/franka_gazebo/launch/panda.launch#L52-L67

Since the ROS (1) launch is nondeterministic this means, that the simulation is started, whenever panda_2 has beed added to Gazebo. It might happen that panda_1 then takes some time until its controller is loaded. During that time, when no controller is present the robot will drift away (See issue 160 for details). When the controller is active the robot should stop drifting. You should also see that in Rviz, that as soon as the interactive marker shows up the drifting stops

To avoid this race condition I suppose you do the following:

  1. Start Gazebo paused
  2. Spawn both robots into the world without unpausing
  3. Once all controllers are loaded, call rosservice call /gazebo/unpause_physics {}

Hope this helps


Also one more hint: Your argument structure looks a bit messy. I suggest you keep the panda.launch file unchanged and pass all custom parameters (initial joint position, controllers, x,y,z ...) in the panda_dual.launch.

YaoweiFan commented 2 years ago

@gollth Thanks for your answer and hints. I've tried what you said, and it's really helpful to me.

gollth commented 2 years ago

If that solved your issue, please consider to close this ticket here