osrf / vrx

Virtual RobotX (VRX) resources.
Apache License 2.0
432 stars 193 forks source link

`vrx.launch` fails in our docker noetic container #250

Closed M1chaelM closed 3 years ago

M1chaelM commented 3 years ago

Attempting to launch VRX with:

roslaunch vrx_gazebo vrx.launch

fails with the following error:

unknown macro name: xacro:wamv_camera
when processing file: /home/username/vrx_ws/src/vrx/wamv_gazebo/urdf/wamv_gazebo.urdf.xacro
RLException: Invalid <param> tag: Cannot load command parameter [wamv/robot_description]: command [['/opt/ros/noetic/lib/xacro/xacro', '--inorder', '/home/username/vrx_ws/src/vrx/wamv_gazebo/urdf/wamv_gazebo.urdf.xacro', 'locked:=false', 'thruster_config:=T', 'vrx_sensors_enabled:=true', 'namespace:=wamv']] returned with code [2]. 

Param xml is <param name="$(arg namespace)/robot_description" command="$(find xacro)/xacro --inorder '$(arg urdf)'          locked:=$(arg wamv_locked)               thruster_config:=$(arg thrust_config)          vrx_sensors_enabled:=$(arg vrx_sensors_enabled)          namespace:=$(arg namespace) "/>
The traceback for the exception was written to the log file

This same command succeeds in launching gazebo on the host using the host-based install instructions, even without rebuilding vrx. Maybe there is a missing dependency in the container?

M1chaelM commented 3 years ago

Continuing to document this issue: Running the xacro command directly fails in the docker image whenever the argument vrx_sensors_enabled:=true is included. This argument indirectly sets camera_enabled to true, which triggers the error. A simpler test is:

/opt/ros/noetic/lib/xacro/xacro /home/username/vrx_ws/src/vrx/wamv_gazebo/urdf/wamv_gazebo.urdf.xacro camera_enabled:=true

This works fine on the host, and fails in the Docker container with a similar error:

unknown macro name: xacro:wamv_camera
when processing file: /home/username/vrx_ws/src/vrx/wamv_gazebo/urdf/wamv_gazebo.urdf.xacro

It seems that this error occurs for all the files in the ~/vrx_ws/src/vrx/wamv_gazebo/urdf/sensors/ directory.

M1chaelM commented 3 years ago

Directly including the macros from the sensors directory in wamv_gazebo.urdf.xacro resolves the issue. So does including the macros.xacro file explicitly by adding the line

  <xacro:include filename="$(find wamv_gazebo)/urdf/macros.xacro"/>

The problem seems to be that when the include directive is given with the wamv_gazebo macro, xacro can't find the macros defined in the included files.

M1chaelM commented 3 years ago

Changing the default value of vrx_sensors_enabled to true in wamv_gazebo.urdf.xacro, i.e.

  <xacro:arg name="vrx_sensors_enabled" default="true" />

causes the build to fail in the Docker image and succeed on the host.

M1chaelM commented 3 years ago

The contents of wamv_gazebo.xacro are:

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <!-- Macro to create a WAM-V with dyanmics plugins and a customizeable thruster layout -->
  <xacro:macro  name="wamv_gazebo" params="thruster_layout">
    <!-- Include macros for dynamics plugins -->
    <xacro:include filename="$(find wamv_gazebo)/urdf/macros.xacro" />
    <!-- Defines the base vehicle -->
    <xacro:include filename="$(find wamv_description)/urdf/wamv_base.urdf.xacro" />
    <!-- Thruster Layout -->
    <xacro:include filename="${thruster_layout}"/>
    <!-- Attach hydrodynamics plugin -->
    <xacro:usv_dynamics_gazebo name="wamv_dynamics_plugin"/>
  </xacro:macro>
</robot>

Changing to the following resolves the problem:

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <!-- Include macros for dynamics plugins -->
  <xacro:include filename="$(find wamv_gazebo)/urdf/macros.xacro" />
  <!-- Macro to create a WAM-V with dyanmics plugins and a customizeable thruster layout -->
  <xacro:macro  name="wamv_gazebo" params="thruster_layout">
    <!-- Defines the base vehicle -->
    <xacro:include filename="$(find wamv_description)/urdf/wamv_base.urdf.xacro" />
    <!-- Thruster Layout -->
    <xacro:include filename="${thruster_layout}"/>
    <!-- Attach hydrodynamics plugin -->
    <xacro:usv_dynamics_gazebo name="wamv_dynamics_plugin"/>
  </xacro:macro>
</robot>

I'm not sure yet why this is the case and why the original works on one system but not the other.

M1chaelM commented 3 years ago

It appears that the ROS GPG Key Expiration Incident was causing package updates on the host to fail, so these were not as up to date as the packages installed on the Docker image. I have now updated them and I'm seeing the same error on both the Docker image and the host. Something in this update appears to have changed the behavior of how include files work. A full list of the packages updated (including a few not related to the ROS problem) is below, but the update to ros-noetic-xacro seems potentially relevant. The changelog for this package has not been updated since October 2020, but I think this may be related to PR 272, which addresses this issue.

Bottom Line

Solution

M1chaelM commented 3 years ago

List of upgraded packages (just in case someone finds a mistake in my reasoning above):

apt 
apt-transport-https
apt-utils
bluez
bluez-cups
bluez-obexd
libapt-pkg6.0
libbluetooth3
libgupnp-1.2-0
linux-base
python3-rosdep
python3-rosdep-modules
ros-noetic-controller-interface
ros-noetic-controller-manager
ros-noetic-controller-manager-msgs
ros-noetic-desktop
ros-noetic-desktop-full
ros-noetic-diff-drive-controller
ros-noetic-effort-controllers
ros-noetic-forward-command-controller
ros-noetic-gazebo-ros-control
ros-noetic-geodesy
ros-noetic-geographic-info
ros-noetic-geographic-msgs
ros-noetic-hardware-interface
ros-noetic-hector-gazebo-plugins
ros-noetic-joint-limits-interface
ros-noetic-joint-state-controller
ros-noetic-joy
ros-noetic-librviz-tutorial
ros-noetic-position-controllers
ros-noetic-robot
ros-noetic-robot-localization
ros-noetic-rqt-robot-plugins
ros-noetic-rqt-rviz
ros-noetic-rviz
ros-noetic-rviz-plugin-tutorials
ros-noetic-rviz-python-tutorial
ros-noetic-simulators
ros-noetic-teleop-twist-joy
ros-noetic-transmission-interface
ros-noetic-urdf-sim-tutorial
ros-noetic-urdf-tutorial
ros-noetic-velodyne-description
ros-noetic-velodyne-simulator
ros-noetic-visualization-tutorials
ros-noetic-viz
ros-noetic-xacro
M1chaelM commented 3 years ago

Resolved with PR #255.