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

Change directory in ROS for all users

asked 2020-04-09 12:00:45 -0500

mustafa404 gravatar image

Hello,

I am working with executable files that are to be included in the main node file. But the problem is I can define the path in my PC and open a text file with or execute the file but it is not universal with my other team members which are part of the team.

I have the following commands:

os.chdir( "/home/user/epsilon/epsilon_catkin_ws/src/knowledge_source/sense_manager/pddl_files/")

os.system("./ff -p /home/user/epsilon/epsilon_catkin_ws/src/knowledge_source/sense_manager/pddl_files/ -o domain.pddl -f problem.pddl >

solution_path = "/home/user/epsilon/epsilon_catkin_ws/src/knowledge_source/sense_manager/pddl_files/solution.txt" solution_detail.txt")

Since the path are unique with my laptop, it will require changes by everyone. IS there a way to make the path definition universal? (The commands are part of the node and not he launch file)

I tried the following pattern but it does not work:

os.chdir( "$(find knowledge_source)/sense_manager/pddl_files/")

knowledge_source is the name of the package

Any recommendations?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-04-09 17:06:57 -0500

Mark Rose gravatar image

It's a bad idea to rely on changing the current directory. It won't even work properly in some languages because of multithreading. Instead, you should use rosrun or roslaunch to start your nodes. Those utilities will find the right location within your workspace so you don't have to hard-code paths. As well, if you need configuration files or output locations, those can be specified as node parameters.

edit flag offensive delete link more

Comments

Thanks for the input. But I am using **rosrun** to start the node and need these commands mentioned in the question for successful service calls in that node. The node is inside the find_knowledge_source package but when i write **( "$(find knowledge_source)/sense_manager/pddl_files//solution.txt")** , it is not able to find the directory

mustafa404 gravatar image mustafa404  ( 2020-04-12 20:54:29 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-04-09 12:00:45 -0500

Seen: 353 times

Last updated: Apr 09 '20