StarlingUAS / ProjectStarling

BRL Flight Arena Infrastructure 2.0
Other
16 stars 3 forks source link

PX4 iris gps0_joint error #125

Closed mhl787156 closed 2 years ago

mhl787156 commented 2 years ago

A bug has recently appeared in the standard starling-sim-iris container in which it complains that gps0_joint is disconnected. I have checked the sdf file in /src/PX4-Autopilot/Tools/sitl_gazebo/models/iris/iris.sdf and nothing seems to have broken.

It may be related to https://github.com/PX4/PX4-SITL_gazebo/issues/536 as it looks like the repository has since updated (https://github.com/PX4/PX4-SITL_gazebo/blob/a1d9dfaff0b081aa3748be9300d0f07149bee8ac/models/iris/iris.sdf.jinja#L421) and the gps is its own model. But unsure as to why it has suddenly stopped working, perhaps the recent rebuild updated something else...

Possible fix is to update the PX4 repository version within the container.

Error

[gzweb_entrypoint.sh-2] Done
[spawn_entity.py-3] [INFO] [1637750845.140874615] [spawn_entity]: Calling service /spawn_entity
[gzweb_entrypoint.sh-2] 
[gzweb_entrypoint.sh-2] > gzweb@1.3.0 start /root/gzweb
[gzweb_entrypoint.sh-2] > if [ $npm_config_port ]; then port=$npm_config_port; fi; cd gzbridge && ./server.js $port
[gzweb_entrypoint.sh-2] 
[gzserver-1] [Msg] Waiting for master.
[gzserver-1] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
[gzserver-1] [Msg] Publicized address: 192.168.1.168
[gzserver-1] [Msg] Loading world file [/usr/share/gazebo-11/worlds/empty.world]
[gzserver-1] [Err] [Model.cc:123] Error Code 23 Msg: FrameAttachedToGraph error, Non-LINK vertex with name [gps0_joint] is disconnected; it should have 1 outgoing edge in MODEL attached_to graph.
[gzserver-1] [Err] [Model.cc:123] Error Code 23 Msg: Graph has __model__ scope but sink vertex named [gps0_joint] does not have FrameType LINK or MODEL when starting from vertex with name [gps0_joint].
[gzserver-1] [Err] [Model.cc:123] Error Code 26 Msg: PoseRelativeToGraph error, Vertex with name [gps0_joint] is disconnected; it should have 1 incoming edge in MODEL relative_to graph.
[gzserver-1] [Err] [Model.cc:123] Error Code 26 Msg: PoseRelativeToGraph frame with name [gps0_joint] is disconnected; its source vertex has name [gps0_joint], but its source name should be __model__.
[spawn_entity.py-3] [INFO] [1637750845.358435270] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [iris_1]
[gzserver-1] [Wrn] [gazebo_gps_plugin.cpp:76] [gazebo_gps_plugin]: iris_1::gps0 using gps topic "gps0"
[gzserver-1] [Msg] Home latitude is set to 51.5016.
[gzserver-1] [Msg] Home longitude is set to -2.55179.

/src/PX4-Autopilot/Tools/sitl_gazebo/models/iris/iris.sdf (relevant chunk):

<sdf version='1.7'>
  <model name='iris'>
    ...
    <model name='gps0'>
      <link name='link'>
        <pose>0 0 0 0 -0 0</pose>
        <inertial>
          <pose>0 0 0 0 -0 0</pose>
          <mass>0.01</mass>
          <inertia>
            <ixx>2.1733e-06</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>2.1733e-06</iyy>
            <iyz>0</iyz>
            <izz>1.8e-07</izz>
          </inertia>
        </inertial>
        <visual name='visual'>
          <geometry>
            <cylinder>
              <radius>0.01</radius>
              <length>0.002</length>
            </cylinder>
          </geometry>
          <material>
            <script>
              <name>Gazebo/Black</name>
              <uri>__default__</uri>
            </script>
          </material>
        </visual>
        <sensor name='gps' type='gps'>
          <pose>0 0 0 0 -0 0</pose>
          <plugin name='gps_plugin' filename='libgazebo_gps_plugin.so'>
            <robotNamespace/>
            <gpsNoise>1</gpsNoise>
            <gpsXYRandomWalk>2.0</gpsXYRandomWalk>
            <gpsZRandomWalk>4.0</gpsZRandomWalk>
            <gpsXYNoiseDensity>0.0002</gpsXYNoiseDensity>
            <gpsZNoiseDensity>0.0004</gpsZNoiseDensity>
            <gpsVXYNoiseDensity>0.2</gpsVXYNoiseDensity>
            <gpsVZNoiseDensity>0.4</gpsVZNoiseDensity>
          </plugin>
        </sensor>
      </link>
    </model>
    <joint name='gps0_joint' type='fixed'>
      <parent>base_link</parent>
      <child>gps0::link</child>
    </joint>
    ...
  </model>
</sdf>
mhl787156 commented 2 years ago

After some investigation, it is definitely linked to https://github.com/PX4/PX4-SITL_gazebo/issues/536 as the sitl_gazebo CMake compiles iris_base.xacro into iris.sdf (https://github.com/PX4/PX4-SITL_gazebo/blob/0da08f0333cd14c08a9545c6ba7ddfc18706398f/CMakeLists.txt#L239). iris base uses the gps xacro which creates a gps model.

The output sdf file then has nested models which cannot be understood by the gazebo parser.

The updated version of PX4 switches to using Jinja and fully deprecates the use of xacro. This would require a re-think of the spawn method as that currently utilises the xacro spawn script.

mhl787156 commented 2 years ago

Jinja would require using something like: https://github.com/PX4/PX4-Autopilot/blob/2e8918da66af37922ededee1cc2d2efffec4cfb2/Tools/gazebo_sitl_multiple_run.sh#L38 instead of xacro within the xacro_launch.sh iris launch file.

mhl787156 commented 2 years ago

Merged with https://github.com/StarlingUAS/ProjectStarling/pull/126