Assign value of a rosparam to a node param in a launch file
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.
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@laura-laptop:~$ rosparam dump
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.