CLI Command: genesys sim
The genesys sim command group provides tools to create and manage Gazebo simulations within your workspace. It standardizes the process of setting up a simulation environment for a robot, which is often a complex and error-prone task.
genesys sim create
Creates a new *_gazebo package in the sim/ directory, fully configured for a specific robot.
Usage
genesys sim create <package_name> --from-pkg <robot_description_package>
<package_name>: The name of the simulation package. By convention, this must end in_gazebo(e.g.,my_robot_gazebo).--from-pkg <robot_description_package>: The name of an existing package that contains the robot's URDF or XACRO files (e.g.,ur_description).
How It Works
This command automates the creation of a complete Gazebo simulation package.
- Directory Creation: It creates a new package inside the
sim/directory (creatingsim/if it doesn't exist). This keeps simulation packages separate from your robot's source code insrc/. - Dependency Check: It runs
rosdep checkandrosdep installto ensure that necessary simulation dependencies likegazebo_ros_pkgsare installed on your system. - Template Rendering: It generates a standard set of subdirectories (
launch,worlds,models,config,urdf) and populates them with boilerplate files rendered from internal templates. This includes:CMakeLists.txtandpackage.xml- A main launch file (
<package_name>.launch.py) to start Gazebo and the robot. - A secondary launch file to spawn the robot model (
spawn_<robot_name>.launch.py). - A default
controllers.yamlfor aros2_controlsetup. default.worldandempty.worldfiles.
- URDF Linking: To ensure the simulation always uses the most up-to-date robot model, it tries to symlink the
urdfdirectory from the source package (--from-pkg) into the new simulation package. If symlinking fails (e.g., due to permissions), it falls back to copying the directory.
Example:
genesys sim create my_robot_gazebo --from-pkg my_robot_description
genesys sim run
Launches a Gazebo simulation from one of the *_gazebo packages.
Usage
genesys sim run <package_name> [options]
<package_name>: The name of the simulation package to run (e.g.,my_robot_gazebo). It must be located in thesim/directory.
Options
--world <world_file.world>: Specify a world file to load from the package'sworlds/directory. Defaults toempty.world.--headless: Run Gazebo in headless mode (no GUI). This is useful for running simulations on a server or as part of a CI/CD pipeline.
How It Works
- Workspace Validation: Checks that the workspace has been built (
install/exists) and the specified<package_name>exists in thesim/directory. - Environment Setup: It modifies the environment for the launch subprocess. This is the key to making Gazebo find all the necessary files. It sets the following environment variables:
GAZEBO_MODEL_PATH: Points to themodelsdirectory in your sim package.GZ_SIM_RESOURCE_PATH: Points to both theworldsandmodelsdirectories.GAZEBO_WORLD: Set to the value of the--worldoption.HEADLESS: Set to1if the--headlessflag is used.
- Execution: It sources the local workspace and executes the main launch file for the simulation package (
ros2 launch <package_name> <package_name>.launch.py) using the modified environment.
Example:
# Run the simulation with a GUI and a specific world
genesys sim run my_robot_gazebo --world my_world.world
# Run the simulation without a GUI
genesys sim run my_robot_gazebo --headless