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

Can not retrieve parameters.

asked 2017-10-19 12:41:42 -0600

Long Smith gravatar image

updated 2017-10-19 14:15:12 -0600

gvdhoorn gravatar image

I am running ur5_moveit_config demo.launch from ros-industrial's universal robot package and I'd like to control it from my node. For that purpose I need to retrieve several parameters from parameter server. The first one is planning_plugin.

Calling rosparam list | grep planning_plugin gives /move_group/planning_plugin. Which means that parameter exists.

Here is my node initialization code:

#include <ros/ros.h>
#include <pluginlib/class_loader.h>

/* Moveit includes */
#include <moveit/robot_model/robot_model.h>
#include <moveit/robot_model_loader/robot_model_loader.h>
#include <moveit/planning_scene/planning_scene.h>
#include <moveit/planning_interface/planning_interface.h>
#include <moveit_msgs/DisplayTrajectory.h>
#include <moveit_msgs/PlanningScene.h>
#include <moveit/kinematic_constraints/utils.h>

#include <iostream>
#include <boost/scoped_ptr.hpp>

int main(int argc, char **argv) {
    ros::init(argc, argv, "arm_control_node");
    ros::AsyncSpinner spinner(1);
    spinner.start();
    ros::NodeHandle node_handle("/move_group/arm_control");

    std::string planner_plugin_name; //= "ompl_interface/OMPLPlanner";

    if (!node_handle.getParam("planning_plugin", planner_plugin_name)) {
        ROS_FATAL_STREAM("Could not find planner plugin name");
    }

    return 0;
}

Launching executable with rosrun arm_control arm_control_node prints [FATAL] [1508419005.957461571]: Could not find planner plugin name. However rosparam get /move_group/planning_plugin outputs ompl_interface/OMPLPlanner.

I have tried to hardcode plugin name as a result I have got an error about retrieving other parameters. It seems like the node can not get access to them but why is a mystery for me.

edit retag flag offensive close merge delete

Comments

I'd like to control it from my node

looking at your #includes: are you planning to load planning plugins directly? That is possible, but just wanted to make sure you are aware there is a ROS API (ie: services and actions) available that is probably much easier to use.

gvdhoorn gravatar image gvdhoorn  ( 2017-10-19 14:16:42 -0600 )edit

@gvdhoorn Thanks again! Gonna take a look. It is just a part of the motion_planning_api_tutorial from moveit page. Wonder why do they use direct plugin loading if there are easier methods to do so.

Long Smith gravatar image Long Smith  ( 2017-10-19 14:45:58 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-10-19 14:14:52 -0600

gvdhoorn gravatar image
ros::NodeHandle node_handle("/move_group/arm_control");
...
node_handle.getParam("planning_plugin", ...);

and:

Launching executable with rosrun arm_control arm_control_node prints [FATAL] [1508419005.957461571]: Could not find planner plugin name. However rosparam get /move_group/planning_plugin outputs ompl_interface/OMPLPlanner.

Parameter lookups are relative to the ros::NodeHandle that you do them with.

In this case you ask for planning_plugin with a NodeHandle that you created in the /move_group/arm_control namespace. So in the end, node_handle will try to retrieve /move_group/arm_control/planning_plugin for you.

That parameter doesn't exist, hence the error.


Do you have a specific reason for creating your main ros::NodeHandle in that namespace?

It is perfectly ok to create NodeHandles in namespaces like that, but especially the "first one" is typically created without any namespace declaration at all.

edit flag offensive delete link more

Comments

Yeah, I've read about it. Actually that was just one of the many attempts to make it work but the first one used global resolution node_handle.getParam("/move_group/planning_plugin", ...) and it failed for some reason(wonder if it was a type since I checked spelling).

Long Smith gravatar image Long Smith  ( 2017-10-19 14:40:39 -0600 )edit

Whatsoever it was, now, thanks to your answer, it works.

Long Smith gravatar image Long Smith  ( 2017-10-19 14:42:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-10-19 12:41:42 -0600

Seen: 1,347 times

Last updated: Oct 19 '17