Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MoveIt+Gazebo Integration tutorial for panda arm #499

Merged
merged 5 commits into from
Mar 10, 2021

Conversation

tahsinkose
Copy link
Contributor

@tahsinkose tahsinkose commented Jun 8, 2020

Description

Addresses #128. Takes over from #493.

Since the panda release used in Setup Assistant doesn't have proper Gazebo details, I had to include them with reference to an external blog. It turned out to be a bit more involved than I expected to be, but it gives a good (and working 🙂 ) sample.

I believe MoveIt Setup Assistant could be perfectionized based on this tutorial, so that the output could be directly usable. Might take a look in it too, but can't promise 😉

@tahsinkose tahsinkose changed the title Pr gazebo Add MoveIt+Gazebo Integration tutorial for panda arm Jun 8, 2020
@davetcoleman
Copy link
Member

@tahsinkose do the changes you need only pertain to panda_description or also the panda_moveit_config packages?

We have full control over the moveit_config:
https://github.com/ros-planning/panda_moveit_config

The description package requires going through Franka's team, but its not so difficult @fwalch. It looks like @erdalpekel has already opened a PR for this (now a year old):
https://github.com/frankaemika/franka_ros/pull/52/files

Copy link
Member

@davetcoleman davetcoleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is a really great improvement to my stub tutorial!

@tahsinkose
Copy link
Contributor Author

@tahsinkose do the changes you need only pertain to panda_description or also the panda_moveit_config packages?

To both.

We have full control over the moveit_config:
https://github.com/ros-planning/panda_moveit_config

Great. Going to make a PR in there.

The description package requires going through Franka's team, but its not so difficult @fwalch. It looks like @erdalpekel has already opened a PR for this (now a year old):
https://github.com/frankaemika/franka_ros/pull/52/files

When I rebased to the latest kinetic-devel, stuff simply stopped working. Therefore that PR might not directly work, even after fixing the merge conflicts. I need to have a deeper look in it.

@erdalpekel
Copy link

erdalpekel commented Jun 11, 2020

Hi,

I can help with the merge/rebase procedure if it's mandatory to merge into a specific branch.
Just let me know!
My PR dates more than a year back so I'm not sure which modifications are necessary / needed for the specific tutorial that you are trying to create for the docs.

Erdal

@tahsinkose
Copy link
Contributor Author

Hi @erdalpekel hocam,

so I'm not sure which modifications are necessary / needed for the specific tutorial that you are trying to create for the docs.

This is independent from any tutorials. MoveIt documentation depends on the latest kinetic-devel/melodic-devel, so rebasing to latest versions of them would do. I can suggest the following:

  1. Fix merge conflicts in Panda in Gazebo + MoveIt! motion planning frankaemika/franka_ros#52 and make it mergeable.
  2. After merge is done wrt frankaemika:kinetic-devel, rebase your simulation branch --onto the frankaemika:melodic-devel.
  3. Fix possible merge conflicts due to step 2.
  4. Create a PR wrt frankaemika:melodic-devel.

After these steps, both versions should have the simulatable robot 🙂

@erdalpekel
Copy link

Hi @tahsinkose,

I will try to fix the conflicts and merge with the branches that you mentioned.

@erdalpekel
Copy link

erdalpekel commented Jun 12, 2020

Just wanted to leave a link to the state of the actual PR here.
I will add a case distinction to the robot description for the simulation. If the Franka Emika team agrees on the changes, the simulation should work in the kinetic-devel and melodic-devel branches.

@tahsinkose
Copy link
Contributor Author

@erdalpekel according to frankaemika/franka_ros#52 (comment), merging changes into franka_ros seems intractable currently. Thanks for your effort!

@davetcoleman I believe we should continue with what we have right now and merge this document, which is already a working piece of knowledge. In the followups, I'll first get a compromise on moveit/panda_moveit_config#68 and could possibly takeover frankaemika/franka_ros#52 from @erdalpekel if he couldn't find the cycles to do so 🙂 .

@tahsinkose
Copy link
Contributor Author

@davetcoleman Can we merge this?

Copy link
Contributor

@JStech JStech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating this tutorial--it's very helpful for a project I'm working on. There were some unclear steps, which I've noted.

such that the necessary components to properly simulate the robot in Gazebo are missing with respect to :code:`urdf` and :code:`xacro` files. This is a rare incident, since most other robots
have those components out of the box. *If you have a custom robot, which already works well in Gazebo, you can skip the steps until Step-6.* Fortunately, there is already a good solution offered in `the blog post <https://erdalpekel.de/?p=55>`_ to this problem. For the sake of completion though,
the procedure outlined in there will be repeated (with improvements) in here as well for preparing the robot for Gazebo simulation.
**Note that these steps assume that you have cloned franka_ros repository from the source**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to include a link to the repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It assumes that the user had followed the Setup Assistant tutorial, which has that link.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Note that these steps assume that you have cloned franka_ros repository from the source**:
**Note that these steps assume that you have cloned the `franka_ros repository <https://github.com/frankaemika/franka_ros>` from the source**:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does have the link, but it also recommends installing the package via apt-get, so I didn't actually need the link until I got to this step, which is why I suggest adding the link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair 👍

<link name="world" />

between lines 3 and 4. Additionally, we should rename the fixed joint to :code:`virtual_joint` to properly match
the SRDF specification created in previous tutorial.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this on line 8? It probably is, but it'd be very helpful to be more specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it is on line 5 without the link name="world" addition in above.

Moreover friction forces are added in order to have realistic dynamics. You can ignore them at all or change their values to experiment.
Since the focus is MoveIt in this tutorial, we will just use the values from the provided solution.

This step is a bit tedious to do manually, so the ultimate :code:`xacro` file is provided entirely in below:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this file go? What should it be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I specified the file name as inline comment:: panda.gazebo.xacro. It should be placed next to the xacro files. Added these to docu as well 👍

</xacro:macro>
</robot>

Then add the following block to the end of :code:`franka_description/robots/panda_arm_hand_urdf.xacro` file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the </robot>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I mean, come on 😅

to control theoretically any type of robot. :code:`gazebo_ros_control` enables the ROS control to be used in Gazebo.
See `its document <http://gazebosim.org/tutorials/?tut=ros_control>`_ for full details.

Add the following to the newly created :code:`panda.gazebo.xacro` file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where in the file? Inside the <robot> tag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just before </robot>. I assumed some level of intimacy..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a tutorial that many first-time users will read though, and it's easy to trip up and get lost on "that should be obvious" things. Better to err on the side of too much detail. Don't forget that if you can write a tutorial in the first place, you automatically tend to underestimate the difficulty.

<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"/>
</gazebo>

For transmissions and actuators we are going to create a new file, :code:`panda.control.xacro`. As before, I will provide the full content now:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this file go?

Copy link
Contributor

@ValerioMagnago ValerioMagnago Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to add the libgazebo_ros_contro.so in a separate xacro file.
Inserting it in the panda.gazebo.xacro will not allow to use multiple time the panda_gazebo macro since we will instantiate multiple gazebo_ros_control plugin that can interfere one with the other. Having a separate macro to add the gazebo_ros_control plugin in my experience is an effective solution. So when you are building a robot you can call several time the panda_gazebo macro with different arm_id and at the end you only add once the gazebo_plugin

I experienced this problem in constructing a cobot composed of a mobile base and a robotic arm. Both where loading the ros_control gazebo plugin and this was generating errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point @ValerioMa 👍

</xacro:macro>
</robot>

Similarly add the following line to the end of :code:`franka_description/robots/panda_arm_hand_urdf.xacro` file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, before </robot>, correct? Please specify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really think end of means just before </robot> in this context.

7. Adjust auto-generated ros_controllers.launch
-----------------------------------------------

Fill the :code:`args` in line 9 with:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be helpful to say exactly where to find the ros_controllers.launch file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair 👍

We have successfully integrated MoveIt and Gazebo ultimately. MoveIt Setup Assistant already does
many work under the hood, but it still misses some parts to provide a proper Gazebo integration. After following
this tutorial you should be able to reproduce this locally for any robot. In case you don't want to be
bothered with all the details, `franka_ros <https://github.com/tahsinkose/franka_ros>`_ and `panda_moveit_config <https://github.com/tahsinkose/panda_moveit_gazebo_config>`_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link to https://github.com/tahsinkose/panda_moveit_gazebo_config is broken--maybe you meant https://github.com/tahsinkose/panda_moveit_config? Also, please say which branches should be used, or link directly to them. Looks like the simulation branch on franka_ros and the melodic-devel branch on panda_moveit_config, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link to https://github.com/tahsinkose/panda_moveit_gazebo_config is broken--maybe you meant https://github.com/tahsinkose/panda_moveit_config?

Yes, thanks for notification 👍

Looks like the simulation branch on franka_ros and the melodic-devel branch on panda_moveit_config, right

Yes to both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bothered with all the details, `franka_ros <https://github.com/tahsinkose/franka_ros>`_ and `panda_moveit_config <https://github.com/tahsinkose/panda_moveit_gazebo_config>`_
bothered with all the details, `franka_ros <https://github.com/tahsinkose/franka_ros/tree/simulation>`_ and `panda_moveit_config <https://github.com/tahsinkose/panda_moveit_config/tree/melodic-devel>`_

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


<!-- panda.gazebo.xacro -->
<?xml version='1.0' encoding='utf-8'?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By a blind copy of the code-block (as I did) you get an error during the urdf generation from xacro file.
Xacro file have to start with <?xml version='1.0' encoding='utf-8'?>.
I suggest therefore to swap line 1 with line 2. In this way we still have the information on the file name which is very useful, but the copy and paste will work.

joints:
- panda_finger_joint1
- panda_finger_joint2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action_ns, type, default, joints should have the same indentation of name both in panda_arm_controller and panda_hand_controller otherwise by just copy and pasting users will get the following error:

ros_controllers.yaml contains invalid YAML:
mapping values are not allowed here
in "", line 63, column 18:
action_ns: follow_joint_trajectory
^
XML is
The traceback for the exception was written to the log file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-pasting stuff between implicitly indented text editors (with their own rules, 2? 4? Or a tab, damn) is a long-lasting pain-in-the-neck for me 🤦‍♂️ Thanks for pointing it out 👍

@ValerioMagnago
Copy link
Contributor

Using the franka_description maintained by franka_emika generate wrong behavior in Gazebo. The problem is that they switched to a simplified collision profile generation (link) that increase the speed in planning since it is easier to detect collision. This work well with moveit since the collision check between subsequent link can be disabled. This can not be done in the gazebo environment and with this simplified collision profile the system will not behave correctly.
At some point I remember that franka_ros was supporting both a simplify collision check and another based on stl files. They had a parameter of the xacro macro to select which collision was needed. Maybe this hybrid solution could give us the possibility to use the simplified xacro for planning and the other for gazebo. But in this way 2 robot_descriptions are needed and this may create confusion.

@felixvd
Copy link
Contributor

felixvd commented Sep 12, 2020

We get regular posts about the Gazebo tutorial being out-of-date (moveit/moveit#2179, moveit/moveit#2237, moveit/moveit#2210), and I had trouble getting this to run today as well.

@tahsinkose Any chance you could incorporate the review comments and confirm that the instructions still work? It would be great if this could be merged soon.

@ValerioMa It shouldn't be a problem to use another URDF in demo_gazebo.launch instead of using the robot_description rosparam to spawn the model.

@tahsinkose
Copy link
Contributor Author

Thanks for the detailed reviews @JStech and @ValerioMa! I have addressed almost all of them and made the defending arguments where the status quo seems better to me.

@ValerioMa That's why I created my fork on top of MoveIt's fork. I tried to make things work with the latest franka upstream, but it turned out to be much more non-trivial than I first expected. Let's just try to improve MoveIt's fork 🤞

@felixvd I didn't try all the instructions back again, but checked the steps involving yamls with indentations and etc. They seem to work. Please retry the steps and write me explicitly via Discord, where the things got wrong, ofc if you could find any.

@tylerjw
Copy link
Member

tylerjw commented Oct 4, 2020

@tahsinkose as we discussed on discord, we'll revisit this after my latest update and the approach I think makes the most sense is for you to provide a patch to our panda_moveit_config to support this tutorial. I'm responding here in case anyone else has a better idea for how to support this tutorial. We have other existing tutorial specific additions to panda_moveit_config for various tutorials and it seems like supporting the more complex collision environment would be a useful modification in this case.

@tahsinkose
Copy link
Contributor Author

@tylerjw support patch is at moveit/panda_moveit_config#68. Please review that and let's merge this long-lasting PR. I followed the documentation once again and it is still working.

@tahsinkose tahsinkose requested a review from felixvd January 23, 2021 11:49
@tahsinkose
Copy link
Contributor Author

I created franka_ros patch at frankaemika/franka_ros#126. If both patches are merged, then this tutorial can be reduced a lot as all necessary changes would have made their way to the upstreams 🙂

PTAL @ValerioMa @felixvd.

@davetcoleman
Copy link
Member

Our main contact at Franka, Sebastian, does not seem to be there anymore (his mail bounced) and @fwalch isn't responding. I think we need to move forward for now assuming we won't have any support from Franka Emika, so having these changes here will probably have to stay.

@davetcoleman
Copy link
Member

CI is passing... what if we just merge this as a first step to getting those gazebo tutorials usable?

@davetcoleman
Copy link
Member

Closes #493

@davetcoleman davetcoleman merged commit cf8c525 into moveit:master Mar 10, 2021
@welcome
Copy link

welcome bot commented Mar 10, 2021

Congrats on getting your first MoveIt pull request merged and improving open source robotics!

@davetcoleman
Copy link
Member

Please create follow up PRs as necessary to finish this, I just want to get some documentation out there on how to use Gazebo with MoveIt

@tahsinkose
Copy link
Contributor Author

Thanks for finally merging this @davetcoleman! Followup PR in tutorial will basically involve removing the steps required to make Gazebo simulation work after the merge of frankaemika/franka_ros#126 and moveit/panda_moveit_config#68.

@tahsinkose tahsinkose deleted the pr-gazebo branch March 11, 2021 19:37
Abishalini pushed a commit to Abishalini/moveit_tutorials that referenced this pull request Apr 29, 2021
* Create stub gazebo simulation tutorial

* Finish pure-gazebo tutorial for panda arm.

* Finish moveit-gazebo tutorial for panda arm.

* Add the missing step regarding to auto-generated robot_description parameter speecification.

* Update external links for panda_moveit_config package in Gazebo tutorial.

Co-authored-by: Dave Coleman <[email protected]>
Co-authored-by: Tahsincan Kose <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants