dairal / ur5_pick_and_place_opencv

Pick and place task with the UR5 that uses an OpenCV service to extract start and goal position from 3D camera data
2 stars 5 forks source link

Pick and Place tutorial not build nor execute out of the box (Ubuntu 20.04) #1

Open 130s opened 1 year ago

130s commented 1 year ago

I came from https://roboticscasual.com/ros-tutorial-how-to-use-opencv-in-a-robot-pick-and-place-task-for-computer-vision/ (Thanks for the tutorial). Find some issues I cannot resolve:

130s commented 1 year ago
  • ur5_gripper_moveit_config package is mentioned, but the package is not found anywhere on Internet as far as I tried.

Ok found at https://github.com/dairal/ur5_gripper_moveit_config.

130s commented 1 year ago

Then

# roslaunch ur5_gripper_moveit_config demo_gazebo.launch world_name:=$(rospack find ur5_pick_and_place_opencv)/world/simple_pick_and_place_collision robot_spawn_position_z_axis:=1.21
... logging to /root/.ros/log/0cdefeaa-b39b-11ed-a669-c85b766a6139/roslaunch-130s-p50-22175.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Traceback (most recent call last):
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/__init__.py", line 347, in main
    p.start()
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/parent.py", line 305, in start
    self._start_infrastructure()
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/parent.py", line 254, in _start_infrastructure
    self._load_config()
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/parent.py", line 156, in _load_config
    self.config = roslaunch.config.load_config_default(self.roslaunch_files, self.port,
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/config.py", line 461, in load_config_default
    loader.load(f, config, argv=args, verbose=verbose)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 763, in load
    self._load_launch(launch, ros_config, is_core=core, filename=filename, argv=argv, verbose=verbose)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 735, in _load_launch
    self._recurse_load(ros_config, launch.childNodes, self.root_context, None, is_core, verbose)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 701, in _recurse_load
    val = self._include_tag(tag, context, ros_config, default_machine, is_core, verbose)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 96, in call
    return f(*args, **kwds)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 635, in _include_tag
    self._recurse_load(ros_config, launch.childNodes, child_ns, \
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 681, in _recurse_load
    self._param_tag(tag, context, ros_config, verbose=verbose)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 96, in call
    return f(*args, **kwds)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/xmlloader.py", line 271, in _param_tag
    value = self.param_value(verbose, name, ptype, *vals)
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/loader.py", line 478, in param_value
    with open(textfile, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/ros/noetic/share/ur_description/urdf/ur5_robotiq85_gripper.urdf.xacro'

I don't find that file anywhere on this host (Docker container).

# find / -iname ur5_robotiq85_gripper.urdf*

Not sure if the content is what the tutorial expects, but I found a file with the same name https://github.com/utecrobotics/ur5/blob/master/ur5_description/urdf/ur5_robotiq85_gripper.urdf.xacro

130s commented 1 year ago

TLDR; I got it at least built and run with tweaks as follows. I leave this up to the blog author how to handle.

  1. Made changes

    $ cd ur5_gripper_moveit_config && git diff
    diff --git a/launch/demo_gazebo.launch b/launch/demo_gazebo.launch
    index 99a1603..9b5a254 100644
    --- a/launch/demo_gazebo.launch
    +++ b/launch/demo_gazebo.launch
    @@ -22,7 +22,7 @@
      <arg name="gazebo_gui" default="true"/>
      <arg name="paused" default="false"/>
      <!-- By default, use the urdf location provided from the package -->
    -  <arg name="urdf_path" default="$(find ur_description)/urdf/ur5_robotiq85_gripper.urdf.xacro"/>
    +  <arg name="urdf_path" default="$(find ur5_description)/urdf/ur5_robotiq85_gripper.urdf.xacro"/>
    
      <arg name="world_name" default="worlds/empty.world"/>
      <arg name="robot_spawn_position_z_axis" default="0.01"/>
    diff --git a/launch/planning_context.launch b/launch/planning_context.launch
    index 0ab4034..7891ea8 100644
    --- a/launch/planning_context.launch
    +++ b/launch/planning_context.launch
    @@ -6,7 +6,7 @@
      <arg name="robot_description" default="robot_description"/>
    
      <!-- Load universal robot description format (URDF) -->
    -  <param if="$(arg load_robot_description)" name="$(arg robot_description)" command="xacro  '$(find ur_description)/urdf/ur5_robotiq85_gripper.urdf.xacro'"/>
    +  <param if="$(arg load_robot_description)" name="$(arg robot_description)" command="xacro  '$(find ur5_description)/urdf/ur5_robotiq85_gripper.urdf.xacro'"/>
    
      <!-- The semantic description that corresponds to the URDF -->
      <param name="$(arg robot_description)_semantic" textfile="$(find ur5_gripper_moveit_config)/config/ur5.srdf" />
    
    $ cd ../opencv_services/ && git diff
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index 0e494a9..806b9e3 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -17,7 +17,8 @@ find_package(catkin REQUIRED COMPONENTS
      message_generation
    )
    
    -find_package(OpenCV 3 REQUIRED)
    +#find_package(OpenCV 3 REQUIRED)
    +find_package(OpenCV 4 REQUIRED)
    
    ## Generate services in the 'srv' folder
     add_service_files(
  2. For Docker image, add entrypoint.
    # more /entrypoint.sh
    #!/bin/bash
    source /opt/kg/setup.bash
  3. Commit a Docker image.
    docker commit --change='ENTRYPOINT ["/entrypoint.sh"]' 7be71e1b791d   ros:noetic-ros-base-focal_dairal-tutorial
  4. Execute with rocker

    export DIMG_ROCKER=ros:noetic-ros-base-focal_dairal-tutorial
    
    rocker --x11 --user $DIMG_ROCKER roslaunch ur5_gripper_moveit_config demo_gazebo.launch world_name:=$(rospack find ur5_pick_and_place_opencv)/world/simple_pick_and_place_collision robot_spawn_position_z_axis:=1.21

And yet, rocker command exits without showing anything.

In the Docker container that started without rocker, the same roslaunch does seem to start processes (but still fails as GUI can't spawn unless I configure it to spawn outside of the container). So now the problem is on my Docker/rocker config.