ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Setting environment variable in local_setup.bash from ament_cmake package

asked 2021-06-03 04:18:57 -0500

amosteo gravatar image

updated 2021-06-08 03:19:42 -0500

Hello,

I'd like to set/modify an environment variable when the user sources the local_setup.bash from compiling my packages with colcon. I haven't succeeded at finding how to do this.

My packages use the ament_cmake build method.

Reading https://colcon.readthedocs.io/en/rele... it seems there are some automated detections done by colcon, and ament_cmake generates its own local_setup.bash. But I do not find how to explicitly say 'set this variable' or if I should generate another script to be sourced, and how I should instruct colcon or ament_cmake to pick it up.

Thanks for any guidance.

Update 2021-05-08

It seems that adding contents to the install/pkg/share/pkg/package.dsvfile should do it. Still not clear how to do this. I've read through https://colcon.readthedocs.io/en/rele... and https://docs.ros.org/en/foxy/Guides/A... and I feel I am near the intended solution. Basically I need to make colcon aware of the existence of a new .dsv file.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-08 04:25:46 -0500

amosteo gravatar image

After some more digging I finally found that what I need is ament_environment_hooks. This is also answered here: https://discourse.ros.org/t/execute-s...

Given that the first google hit is the source code itself and the second one is that question, and the rest are increasingly obscure souces in foreign script, I consider myself satisfied that as simple as it may be it wasn't obviously documented.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2021-06-03 04:18:57 -0500

Seen: 506 times

Last updated: Jun 08 '21