turtlebot / turtlebot_apps

A group of simple demos and exmaples to run on your TurtleBot to help you get started with ROS and TurtleBot.
http://www.ros.org/wiki/turtlebot_apps
196 stars 225 forks source link

Environment variable support for a map file #104

Closed stonier closed 10 years ago

stonier commented 10 years ago

We tried to do this in #103, but failed since it couldn't set a default value for optenv to point to a ros package path.

We can however do this with environment hooks. Actually this is a good way to set all of our variables for turtlebot. e.g. we need turtlebot_bringup/env-hooks/25-turtlebot.sh.em:

# Set some sane defaults for the turtlebot launch environment
export TURTLEBOT_BASE=kobuki                           # create, roomba
export TURTELBOT_BATTERY=/sys/class/power_supply/BAT0  # /proc/acpi/battery/BAT0 in 2.6 or earlier kernels,  /sys/class/power_supply/ (kernels 3.0+) 
.... replicate others from minimal.launch and also add
export TURTLEBOT_MAP_FILE=`rospack find turtlebot_navigation`/xxxx

Then register these environment hooks in turtlebot_bringup/CMakeLists.txt with a line like (I think sh will work for us, but we may need to use bash):

catkin_add_env_hooks(25.turtlebot SHELLS sh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks)

Then configure minimal.launch to use env instead of optenv (so that it forces us to use these environment variables).

And finally pick up the environment variable as a default for the map server similar to what was done in #103.

stonier commented 10 years ago

This is nice - it sets the variables so the user can just do a env | grep TURTLEBOT_ to see what environment variables he can play with.

jihoonl commented 10 years ago

Is this done?

kentsommer commented 10 years ago

Yes. See: https://github.com/turtlebot/turtlebot/commit/c5658a74d79f9b626fa8562132b0d0238850d411 and 75f6f857e2c8bd48a4dc412869e22bba7cdd9be8