Build the Gazebo plugins and lunar pole rover model for Harmonic as well as Fortress (part of #36, fixes #44, #45) - #46
Closed
asimonov wants to merge 4 commits into
Closed
Conversation
…). SolarPanelPlugin, RechargeableBatteryPlugin, SensorPowerSystemPlugin and RadioisotopeThermalGeneratorPlugin were written against the Ignition Fortress API and, since space-ros#41, only built on Humble. They now target the Gazebo Harmonic (gz-sim 8) API: gz::sim, gz::rendering and gz::sensors namespaces, gz/ header paths, the GZ_ADD_PLUGIN registration macros and the gz* console macros. Each message type gets its own include, as gz-msgs 10 no longer provides them transitively. Fortress ships gz/ redirect headers for all of these namespaces but not for the GZ_ / gz prefixed macros, so plugins/gz_compat.hh maps those onto their Ignition names when they are missing. One set of sources therefore builds on both distributions; CMakeLists.txt and package.xml select the Ignition system packages on Humble and the ROS gz_*_vendor packages otherwise, and the environment hook sets both IGN_GAZEBO_* and GZ_SIM_* paths.
…e-ros#44). Gazebo runs ISystemPostUpdate systems on parallel worker threads. SolarPanelPlugin created a rendering RayQuery and cast it from PostUpdate, so the three panel instances on the rover hit the Ogre scene concurrently with each other and with the Sensors system's render thread. Under Harmonic that corrupts the heap within seconds of the rover spawning (malloc_consolidate, std::bad_alloc, SIGSEGV or SIGBUS depending on the run). Disabling this one plugin makes the crash go away; disabling either of the other two does not. Move all rendering access into a gz::sim::events::PostRender callback, which runs on the render thread. PostUpdate now only reads the entity state it needs from the ECM, hands the sun-to-panel ray to the render thread under a mutex, takes back the latest line-of-sight result and publishes the power output. The power computation itself is unchanged. The unused static scene event and SetScene hook are removed, and the ray query is created once instead of on every simulation step.
…ros#36). The ros2_control hardware plugin and the Gazebo system plugins have different names on the two: ign_ros2_control/IgnitionSystem and ignition-gazebo-*-system on Fortress, gz_ros2_control/GazeboSimSystem and gz-sim-*-system on Harmonic. xacro properties keyed on ROS_DISTRO select the right set, so the same model serves the Humble demo and the Jazzy one. The gz_ros2_control plugin also referenced its controller configuration via $(find lunar_pole_exploration_rover), coupling the model to a package in the demos repository. The configuration now lives with the model, as the curiosity rover's does.
…ames (space-ros#45). ROS 2 tf2 frame ids must not start with a slash. The demo's odom_tf_publisher copies the frame names from the odometry message into /tf, so the transform went out as /odom -> /base_footprint and only resolved because tf2 strips the slashes on the way in. The curiosity model has the same names; left for a separate change since the space_robots and nav2 demos build on it.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #36 (does not close it), fixes #44 and #45.
Of the two items in #36, the environment hook is done here for all models (
GZ_SIM_RESOURCE_PATHalongsideIGN_GAZEBO_RESOURCE_PATH), and the ros2_control tags are updated for the lunar pole rover only. The canadarm and curiosity models in this repository still carry the Ignition-onlyign_ros2_control/IgnitionSystemtags; the Jazzycanadarm2andcuriosity_roverdemos are unaffected because they ship their own model copies, but #36 should stay open until those two models get the same treatment.Makes the simulation package build and run on Gazebo Harmonic / ROS 2 Jazzy while keeping Ignition Fortress / ROS 2 Humble working. Four commits:
Build the Gazebo plugins for Harmonic as well as Fortress —
SolarPanelPlugin,RechargeableBatteryPlugin,SensorPowerSystemPluginandRadioisotopeThermalGeneratorPluginnow target the gz-sim 8 API (gz::sim/gz::rendering/gz::sensors,gz/headers,GZ_ADD_PLUGIN,gz*console macros, per-message includes for gz-msgs 10). Fortress shipsgz/redirect headers for all of those namespaces but not for theGZ_/gzprefixed macros, so a 60-lineplugins/gz_compat.hhmaps those onto their Ignition names when absent. One source tree builds on both;CMakeLists.txtandpackage.xmlpick the Ignition system packages on Humble and the ROSgz_*_vendorpackages otherwise (so on Jazzy the plugins link against the same libraries asros_gzandgz_ros2_control), and the environment hook sets bothIGN_GAZEBO_*andGZ_SIM_*paths. Since Building packages onjazzythat includesimulationbreaks due to missing humble dependencies #41 the plugins were excluded from non-Humble builds; this makes them available again.Run the solar panel line-of-sight ray cast on the render thread (SolarPanelPlugin corrupts the heap on Gazebo Harmonic: rendering from PostUpdate #44) — the one non-mechanical change, found by running the plugins under Harmonic. Gazebo executes
ISystemPostUpdatesystems on parallel worker threads, andSolarPanelPlugincreated and cast a renderingRayQueryfromPostUpdate. The rover's three panel instances therefore hit the Ogre scene concurrently with each other and with the Sensors system's render thread, corrupting the heap within seconds of spawning (malloc_consolidate(): invalid chunk size→std::bad_alloc, or SIGSEGV / SIGBUS on other runs). Bisecting by disabling one plugin at a time: only disabling this plugin keeps the server alive. All rendering access now happens in agz::sim::events::PostRendercallback on the render thread;PostUpdatehands the sun-to-panel ray over under a mutex and takes back the latest line-of-sight result. The power computation is unchanged, and the ray query is created once instead of on every simulation step. The same structure runs on Fortress.Make the lunar pole rover model work on Fortress and Harmonic — xacro properties keyed on
ROS_DISTROselectign_ros2_control/IgnitionSystem+ignition-gazebo-*-systemorgz_ros2_control/GazeboSimSystem+gz-sim-*-system, so the one model serves both the existing Humble demo and the Jazzy one. The rover's controller configuration also moves here, next to the model, instead of being referenced through$(find lunar_pole_exploration_rover)in the demos repository (as the curiosity rover's is).Drop the leading slashes from the lunar pole rover's odometry frame names (Rover odometry frame names start with a slash (/odom, /base_footprint) #45) —
/odom→odom,/base_footprint→base_footprintin the odometry publisher config. ROS 2 tf2 frame ids must not start with a slash; the demo'sodom_tf_publishercopies the names into/tf, and the transform only resolved because tf2 strips them on the way in. Verified on Harmonic: the odometry message and/tfnow carryodom→base_footprint, andtf2_echo odom base_linkresolves. The curiosity model has the same names (also noted in Rover odometry frame names start with a slash (/odom, /base_footprint) #45) and is left alone here sincespace_robotsandnav2_demobuild on it.The canadarm, curiosity and lunar terrain models are otherwise untouched.
Effect on consumers
Every demo that builds this package on Jazzy (
space_robots,lunar_terrain) previously got asimulationpackage with no plugins; it now compiles the four plugins as well, which adds well under a minute to the build and declaresgz_{sim,plugin,common,rendering,sensors}_vendoras dependencies — the same vendor stack both demos already pull in forros_gzandgz_ros2_control(space_robotsbuilds those from source;lunar_terraininstallsros-jazzy-ros-gz), so no new class of dependency. Nothing those demos take from the package (the model directories) changes. On Humble (lunar_pole_exploration_roveronmain) the build is the same as before.Checked by building the current
demosmainDockerfiles of all three against this branch (arm64, one edit each to clone this branch instead ofmain):lunar_pole_exploration_roveron Humble (67 packages),space_robots(53 packages) andlunar_terrain(11 packages) all build clean. The Humble image was also run headless: the server stays up with all four plugins loaded from the image build, the solar panel publishes ~106.7 W and the battery 30 V / 100 %, with no crash output.Verification
Built from this branch on both distributions: 1 package finished, 0 warnings on each.
osrf/space-ros:humble-2024.10.0+ system Ignition packages)ros:jazzy-ros-core-noble+ros-jazzy-gz-*-vendor)gz plugin --info/ign plugin --infosimulation::*simulation::*IgnitionSystem,libign_ros2_control-system,ignition-gazebo-*-systemGazeboSystem,gz_ros2_control-system,gz-sim-*-systemIGN_GAZEBO_SYSTEM_PLUGIN_PATHsetGZ_SIM_SYSTEM_PLUGIN_PATHsetJazzy end-to-end, with this branch built into the Gazebo container of the space-ros/demos companion PR (Gazebo server headless under EGL, demo nodes in a separate Space ROS container): the rover spawns on the Mons Mouton terrain, all four ros2_control controllers activate,
/move_forwardmoves it 1.3 m and/rotate_on_placeturns it, the left solar panel reads 106.8 W (the same value the Fortress build produced) and rises to 128.1 W as the rover turns towards the sun, the battery reports 30 V / 100 %, and the navcams stream 2048x2048mono16frames withCameraInfo.Note: the build host is aarch64; all packages involved are available for arm64 and nothing here is architecture-specific.