Ask Your Question
1

Assign value of a rosparam to a node param in a launch file

asked 2017-04-02 06:10:31 -0600

dgerod gravatar image

updated 2017-04-02 06:14:52 -0600

I would like to configure the "mongodb_store" as it uses for database_path a directory path that it is stored in a parameter of the ROS server.

The path is stored as "/rosplan/database_path", see below.

<launch>
    <param name="/rosplan/domain_path" value="$(find pepito_organizes_boxes)/configuration/domain.pddl" />
    <param name="/rosplan/database_path" value="$(find pepito_organizes_boxes)/common/mongoDB" />
</launch>

To achieve this I am calling "rosparama get /rosplan/data_path" in the "command" keyword of "database_path" param" required by "mongodb_store".

<launch>    
    <!-- load configuration -->
    <include file="$(find pepito_organizes_boxes)/launch/load_system_config.launch" />

    <!-- knowledge base -->
    <node name="rosplan_knowledge_base" pkg="rosplan_knowledge_base" type="knowledgeBase" respawn="false" output="log" />
    <node name="rosplan_scene_database" pkg="mongodb_store" type="mongodb_server.py" respawn="false" output="screen" >
        <param name="database_path" command="/bin/bash -c 'rosparam get /rosplan/database_path' -- " />
    </node>
    <node name="rosplan_scene_message_store" pkg="mongodb_store" type="message_store_node.py" respawn="false" output="log" />
 </launch>

It does not work, and output of the console is:

SUMMARY
========

PARAMETERS
 * /rosdistro: indigo
 * /rosplan/data_path: /home/dieesrod/Wo...
 * /rosplan/database_path: /home/dieesrod/Wo...
 * /rosplan/domain_path: /home/dieesrod/Wo...
 * /rosplan/planner_path: /home/dieesrod/Wo...
 * /rosplan/problem_path: /home/dieesrod/Wo...
 * /rosplan/strl_file_path: /home/dieesrod/Wo...
 * /rosplan_scene_database/database_path: /home/dieesrod/Wo...
 * /rosversion: 1.11.20

process[rosplan_knowledge_base-1]: started with pid [6332]
process[rosplan_scene_database-2]: started with pid [6333]
process[rosplan_scene_message_store-3]: started with pid [6341]
[INFO] [WallTime: 1491130707.159727] Mongo server address: localhost:27017
[INFO] [WallTime: 1491130707.171976] Found MongoDB version 2.4.9
[ERROR] [WallTime: 1491130707.172236] Can't find database at supplied path /home/dieesrod/Workspaces/ROS/indigo/anchoring/src/anchoring_system/experiments/pepito_organize_boxes/common/mongoDB
. If this is a new DB, create it as an empty directory.
[rosplan_scene_database-2] process has died [pid 6333, exit code 1, cmd /opt/ros/indigo/lib/mongodb_store/mongodb_server.py __name:=rosplan_scene_database __log:=/home/dieesrod/.ros/log/17adeaa4-1765-11e7-b57a-a4c49440ffa1/rosplan_scene_database-2.log].
log file: /home/dieesrod/.ros/log/17adeaa4-1765-11e7-b57a-a4c49440ffa1/rosplan_scene_database-2*.log
[ERROR] [WallTime: 1491130717.404485] Can't connect to MongoDB server. Make sure mongodb_store/mongodb_server.py node is started.

In fact, when I get the information of "/rosplan/database_path" and "/rosplan_scene_database/database_path" there are some extra spaces in the second one.

$ rosparam get /rosplan/database_path
/home/dieesrod/Workspaces/ROS/indigo/anchoring/src/anchoring_system/experiments/pepito_organize_boxes/common/mongoDB

$ rosparam get /rosplan_scene_database/database_path
'/home/dieesrod/Workspaces/ROS/indigo/anchoring/src/anchoring_system/experiments/pepito_organize_boxes/common/mongoDB

  '

Do you know why this is happening? And how I could solve this situation? I am using ROS Indigo running on Ubuntu 14.04 LTS.

Thanks in advance.

edit retag flag offensive close merge delete

Comments

1

Weird. I also see those spaces when calling rosparam get, but only for some parameters. Maybe post a separate question just about those? It seems that if you could figure that out, the rest of the launch file would work.

lindzey gravatar imagelindzey ( 2017-04-05 04:57:19 -0600 )edit

lindzey@laura-laptop:~$ rosparam dump

rosdistro: 'indigo

  '
rosversion: '1.11.20

  '
run_id: 5e4f6c82-19ac-11e7-ad29-001c422b7714
lindzey gravatar imagelindzey ( 2017-04-05 04:59:27 -0600 )edit

Thanks for your answer.

Yes, but I don't know how to remove them. Therefore, I following a workaround, I map the parameters using a python script that I call inside my launch file.

dgerod gravatar imagedgerod ( 2017-04-05 06:01:20 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-04-05 06:07:17 -0600

dgerod gravatar image

updated 2017-04-05 06:11:15 -0600

I found a workaround for the problem.

I created a python script named as "set_components_config.py", it is responsible of mapping the global parameters to the parameters of each component (e.g. rosplan_scene_database).

#! /usr/bin/env python

import rospy

rospy.set_param("rosplan_scene_database/database_path",
    rospy.get_param("/rosplan/database_path"))

rospy.set_param("rosplan_planning_system/problem_path",
    rospy.get_param("/rosplan/problem_path"))
rospy.set_param("rosplan_planning_system/data_path",
    rospy.get_param("/rosplan/data_path"))
rospy.set_param("rosplan_planning_system/strl_file_path",
    rospy.get_param("/rosplan/strl_file_path"))

And this script is called by the launch file after loading the global parameters and before starting the nodes that use them.

<launch>
    <!-- load configuration -->
    <include file="$(find pepito_organizes_boxes)/launch/load_system_config.launch" />
    <node name="update_config" pkg="pepito_organizes_boxes" type="set_components_config.py" output="screen" />

    <!-- knowledge base -->
    <node name="rosplan_knowledge_base" pkg="rosplan_knowledge_base" type="knowledgeBase" respawn="false" output="log" />
    <node name="rosplan_scene_database" pkg="mongodb_store" type="mongodb_server.py" respawn="false" output="screen" />
    <node name="rosplan_scene_message_store" pkg="mongodb_store" type="message_store_node.py" respawn="false" output="log" />    
</launch>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-04-02 06:10:31 -0600

Seen: 379 times

Last updated: Apr 05 '17