Generators
Part of the appeal of using the robot YAML configuration file is that it allows us to generate the necessary files to operate the robot at runtime. There are 4 types of files that need to be generated: bash shell scripts, URDF description files, launch files, and parameter files. Each file type has a generator which will use the Clearpath Config to figure out which files need to be created, and what the contents should be. Each generator also has a writer class which contains methods for writting formatted lines specific to the file type.
Generator scripts do not need to be modified by the user. Rather the user should modify their robot YAML file to suit their needs.
Bash
The main bash script that needs to be generated is the setup.bash
file. This file will source the Humble setup.bash
, as well as any
additional workspaces. It will also contain environment variables for setting up ROS 2. This file will be sourced by the robot_upstart
job, as well
as the user terminal. This way we can ensure that the bash environment of the upstart jobs matches the user's.
Description
The description generator will generate a robot.urdf.xacro
file which will define the robot. By parsing the robot YAML file, we can determine which
platform the robot is using, as well as which mounts, accessories, and sensors will need to be added on top of the platform. This URDF file will later
be used with the robot state publisher to publish all of the static transforms that make up the robot.
Launch
The launch generator creates ROS 2 python launch files. It will create both the platform and sensor launch files by parsing the robot config. Typically, the generated launch file will include a default launch file, and pass in launch arguments as appropriate. Python classes have been defined for adding other launch files, nodes, and processes to the generated launch file, making it intuitive to use.
Parameter
The parameter generator creates .yaml
ROS parameter files that are used by the corresponding launch file. Each node has default parameters set that the user can overwrite by setting them in the robot configuration YAML.
Setup folder structure
Once all files are generated, the resulting setup folder structure under /etc/clearpath/
will look like this:
- platform
- launch
- platform-service.launch.py
- config
- control.yaml
- imu_filter.yaml
- localization.yaml
- teleop_interactive_markers.yaml
- teleop_joy.yaml
- twist_mux.yaml
- launch
- sensors
- launch
- sensors-service.launch.py
- camera_0.launch.py
- camera_1.launch.py
- ...
- config
- camera_0.yaml
- camera_1.yaml
- ...
- launch
- robot.urdf.xacro
- robot.yaml
- setup.bash