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

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

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

harrynick gravatar image

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

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
0

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

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

Comments

1

Alternatively you can direclty read the environment variable in C++ using std::getenv() https://en.cppreference.com/w/cpp/uti...

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

Thank you soo much both :)

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

Question Tools

1 follower

Stats

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

Seen: 99 times

Last updated: Apr 27 '20