AndrejOrsula / ign_moveit2_examples

C++ and Python examples of using MoveIt 2 inside Ignition Gazebo simulation environment
BSD 3-Clause "New" or "Revised" License
104 stars 22 forks source link

Robot not spawning! #20

Closed kkishore9891 closed 2 years ago

kkishore9891 commented 2 years ago

Hello. I followed the instructions and I tried to spawn the robot but it doesn't spawn properly. Here is a list of all the things I did:

1) I installed ROS Galactic using binaries. 2) Installed ros_ign packages for ros-galactic and ignition-fortress combination (built from source by following: https://github.com/gazebosim/ros_gz/tree/galactic), however rosdep update seems to install ros_ign_gazebo and ros_ign_bridge through binaries as well. I am not sure though. 3) Then I installed ign_ros2_control for ignition fortress and ros-galactic combination by building from source using this (https://github.com/ros-controls/gz_ros2_control). The cartpole examples provided in ign_ros2-control_demos worked as shown in the video attached ( https://user-images.githubusercontent.com/34810513/176423911-3a1cd714-11d1-40b5-909d-67adeecfb051.mp4 ) thus I believe all the steps so far have been followed properly.

Then I went to install the ign_moveit2_examples repo. I had to create a new workspace for this since my previous repo was built using just the "colcon build" command and not "colcon build --merge-install --symlink-install --cmake-args "-DCMAKE_BUILD_TYPE=Release""

Things got built properly and when I try to launch "ros2 launch ign_moveit2_examples ex_cpp_follow_target.launch.py" It doesn't work quite well.

Refer this video to see the exact error ( https://user-images.githubusercontent.com/34810513/176426113-2a76ec14-0525-4cd3-bb2c-3f2839924e9c.mp4 )

kkishore9891 commented 2 years ago

There seems to be a bit of progress in the issue. I removed the binary ros_ign_gazebo and similar dependency packages which I had already built from source and I seperately build the panda_ign_moveit package instead of using the dependency one from ign_moveit2_examples and the robot seems to spawn now but the problem now is that though I can generate new plans by moving the cube in gazebo, I am not able to execute the plan to control the robot with it as shown in this video.

https://user-images.githubusercontent.com/34810513/176461548-0cabb936-ec34-4dc6-a12d-f78813749f6a.mp4 Here is the log that I got in the terminal which I got while executing the script: log.txt

AndrejOrsula commented 2 years ago

Hello @kkishore9891,

The original issue is with libbackward.so (backward_ros) missing, which is a transitive dependency from MoveIt 2 (relevant issue). I thought it was fixed upstream already, but I added the dependency also under panda_ign_moveit2 so you don't need to worry about it.

I simplified the instructions and added Dockerfile that you can follow in case something goes wrong again. Please, follow the instructions again (only ROS 2 galactic and Ignition Gazebo fortress need to be installed externally now, everything else is handled via vcstool and rosdep automatically).

AndrejOrsula commented 2 years ago

Also, make sure that ign gazebo --versions returns only 6.y.z. There could be some issues if your system has multiple different versions of Ignition Gazebo.

kkishore9891 commented 2 years ago

Hello Andrej!!!! It works now!!! Finally!! I have been battling with this for weeks. You are a life saver! Thank you so much!

kkishore9891 commented 2 years ago

By the way, I have 2 more doubts:

1) Is there any possibility to move all this work to ROS humble anytime soon? 2) What should I do to simply swap out the panda robot with a UR5 robot? It would be preferable if I could integrate Moveit2 with a UR5 Robot sdf file instead of urdf file as I plan to add a tiny camera with a plugin to the end effector. It would be great if you could give me a direction in which I can proceed towards that goal.

Thank you in advance.

AndrejOrsula commented 2 years ago
  1. I had issues with getting gz_ros2_control to work on humble/rolling (https://github.com/ros-controls/gz_ros2_control/issues/62). I have not tested it since opening the issue, so it might be fixed already :thinking:. Everything else should just work.
  2. Have URDF model of UR5 (you can add camera inside <gazebo> tag of URDF and it will get converted to SDF camera sensor, I think that it the most straight-forward approach). Then add gz_ros2_control interface for the robot (someone else might have already done it for UR5, which can save you some time). I would start by looking at the official ROS 2 repo for UR robots and see what they already have. If you want and cannot find anything else, then you could use panda_ign_moveit2 as a template and see what needs to be added (there are several ways of achieving the same goal, so you might want to use something else as a template too).
kkishore9891 commented 2 years ago

Thank you so much Andrej! I will close this issue since everything has been sorted up for me!

AndrejOrsula commented 2 years ago

FYI, I tested gz_ros2_control with new changes and it works now on humble/rolling (for the included demos). Therefore, it should be possible to use this repository (and other related repositories) with both humble and rolling. I will try to test it later when I have time for it.

kkishore9891 commented 2 years ago

Awesome! I will keep an eye out for it. Thank you!

kkishore9891 commented 2 years ago

Hello Andrej! I hope you are doing well. I am have been trying to get the UR5 ign moveit2 interface working. I have been building on top of this repo: https://github.com/gezp/universal_robot_ign where I got the UR5 robot to spawn in ignition and have it go to a specified joint configuration or joint position using pymoveit interface or something loosely based on it. However, my application requires controlling the robot using a keyboard or a joystick using servoing. Thus I have been trying to mimic the ex_servo.py example present in the pymoveit repository that you have: https://github.com/AndrejOrsula/pymoveit2/blob/master/examples/ex_servo.py

Here are the things that I have done so far: 1) I changed the move_group_server script which launches moveit_ros_group node, starts ros_ign gazebo and spawn the robot and rviz etc (https://github.com/gezp/universal_robot_ign/blob/main/launch/ur10_move_group_server.launch.py) to also call the moveit_servo executable just like in the move_group.launch.py provided in panda_moveit_config repo that you use for your pymoveit2 examples (https://github.com/AndrejOrsula/panda_ign_moveit2/blob/master/panda_moveit_config/launch/move_group.launch.py). I have attached my modified script here: ur5_move_group2.launch.py.txt

I do believe this achieves atleast something because running ros2 topic list and ros2 service list shows these topics and services (refer the attached images) Screenshot from 2022-07-04 15-54-02 Screenshot from 2022-07-04 15-57-15 Screenshot from 2022-07-04 15-57-39 Screenshot from 2022-07-04 15-58-26

After this I replicated the ex_servo.py (https://github.com/AndrejOrsula/pymoveit2/blob/master/examples/ex_servo.py) and the moveit2_servo.py (https://github.com/AndrejOrsula/pymoveit2/blob/master/pymoveit2/moveit2_servo.py) from the pymoveit2 repo and modified it to suit the ur5 robot. I have attached the scripts below. ex_servo.py.txt moveit2_servo.py.txt ur5.py.txt

After implementing these changes I tried to launch the script but nothing seems to happen.

The different between running the goal_pose and joint configuration demo vs the moveit servo demo has been demonstrated in the video attached here:

https://user-images.githubusercontent.com/34810513/177172636-0bc37a8b-7790-4278-94f0-fd91140a2078.mp4

Do you have any idea as to what could be the problem because the code seems to work for panda robot but seems to suffer for ur5 robot. By the way I was able to get the camera working for the ur5 robot by simply modifying the sdf file as shown in this video below:

https://user-images.githubusercontent.com/34810513/177171389-ff24d8e5-850c-469b-b77d-79ee2cc91e1d.mp4

I initially thought the camera could be causing the error and I disabled the camera plugins and joints but it doesn't seem to solve the error for me unfortunately. Is there anything that could be done to get the servoing working for the ur5 robot?

Thank you in advance!

AndrejOrsula commented 2 years ago

Try looking at the errors you are getting as they describe exactly what is going on. There is a lot of errors related to the invalid coordinate frame used in the planning context (barely visible in the last video because it is covered). Your servo.yaml might be incorrect. Similarly, you are using some unknown joints wheel_*_joint that are not part of your ur5 robot description. The original author of that repository will know more as I have never used it.

kkishore9891 commented 2 years ago

Hello Andrej! The wheel joint error is a completely random error and it disappeared once I restarted the computer. Also the coordinate frame error was an error from a video I recorded long ago and that doesn't seem to be popping up now either. This video provides a clearer view of all the errors and stuff:

https://user-images.githubusercontent.com/34810513/177182949-037f5fe7-3171-4d2b-8ba1-0f893407a188.mp4

https://user-images.githubusercontent.com/34810513/177183167-3c7557ac-040a-4daa-bbbf-a22cb9f7d71b.mp4

regarding the servo.yaml (servo.yaml.txt ) I changed the names of the base and end effector link and the group names by referring the srdf file provided here: ur5.srdf.txt

The funny thing is the move group server script of the ur5 moveit repo (https://github.com/gezp/universal_robot_ign/blob/main/launch/ur10_move_group_server.launch.py) is inspired from your move_group script of an archived repo of yours (https://github.com/AndrejOrsula/panda_moveit2_config/blob/master/launch/move_group_action_server.launch.py) thus I assume the authors to have their work inspired from your work and the authors seems to have no moveit_group and pymoveit servo implementations for UR5 yet. Your repository is the only one I found on the internet which has a pymoveit servo implementation apart from the servo implementation of panda robot provided in moveit2 tutorials which is a C++ demo.

Could the new error messages related to joint_state_broadcaster be of any relevance? Sorry for the trouble. You seem to be the most knowledgeable guy regarding pymoveit, moveit2 and robot arms in general and I couldn't find a better person to ask my queries on the internet!

AndrejOrsula commented 2 years ago

Your ur5_ign.launch.py likely spawns the controllers already, no idea if there are some errors as it is hidden but it seems fine. I am not sure what you are trying to run in your second demo launch script but maybe merge them if possible. For Servo, try disabling collision checking as check_collisions: false in servo.yaml. It seems to be doing what it should, but maybe it's just not moving because it thinks it is in collision.

AndrejOrsula commented 2 years ago

Also, are you sure that your ex_servo.py would result in a motion that robot can accomplish?

kkishore9891 commented 2 years ago

Hello Andrej! I have a good news! I figured out the problem. Just like you said, I set check_collisions to false and I merged move_group_demo and ur5_ign into a single file and I removed the redundant controllers spawns from the scripts. But the most important thing that I had to do was to change the command_out_topic in servo.yaml from /joint_trajectory_controller/joint_trajectory to /set_joint_trajectory which was the topic to which those commands actually had to be published. This allowed me to move the robot as shown below:

https://user-images.githubusercontent.com/34810513/177500332-3749bf7f-8248-4bc6-9030-d5d98b5587c9.mp4

AndrejOrsula commented 2 years ago

Good job!