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

How to load values in bash file to a cpp file??

asked 2020-04-27 05:29:57 -0600

harrynick gravatar image

updated 2021-04-24 02:42:58 -0600

miura gravatar image

I have mentioned ROBOT_INITIAL_POSE in bashrc file using export command...I want to use those values in one of my cpp files...How can i dircetly access those values??

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-27 08:50:14 -0600

Thomas D gravatar image

This question is not really related to ROS, but I'm going to answer as if you are using your C++ file as part of a ROS node. In that case you can use roslaunch to start your node, and in your launch file you can read the value of an environment variable as a substitution argument. That value can then be passed to your node as a parameter.

edit flag offensive delete link more



Alternatively you can direclty read the environment variable in C++ using std::getenv()

jgdo gravatar image jgdo  ( 2020-04-28 09:54:26 -0600 )edit

Thank you soo much both :)

harrynick gravatar image harrynick  ( 2020-04-28 22:23:16 -0600 )edit

Question Tools

1 follower


Asked: 2020-04-27 05:29:57 -0600

Seen: 99 times

Last updated: Apr 27 '20