Environment Hooks
Create
Create a shell file in an env-hooks subfolder.
- The magic ':' notation just sets the environment to the variable if it hasn't already been set by the user.
- The number on the filename represents the priority that ros loads it amongst otherenv-hooks files in etc/catkin/profile.d
You also need this in CMakeLists.txt
CMakeLists.txt
catkin_add_env_hooks(25.turtlebot SHELLS sh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks)
Unique Prefixes
We generally prefix the robot name to any variable.
Avoids potential variable conflicts (robot names are generally unique in the ros world)
- Doesn't override any variables configured by lower level packages
- This is a familiar C style macro convention
- Easily visible to users via
'env | grep TURTLEBOT'
For the second point, consider turtlebot, gopher both trying to set their own ROBOT_NAME, someone would get blown away. There was an interesting thread about this in turtlebot/#177.
Introspection
To get something like roslaunch achieves with arg doc tags, export environment variables with a DESCRIPTION suffix that describes what their namesakes do. For example,
export TURTLEBOT_FOO=bar export TURTLEBOT_FOO_DESCRIPTION="the magic foo that will be used [options: foo, bar, foobar]"