0
$\begingroup$

Rosanswers logo

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.


Originally posted by Long Smith on ROS Answers with karma: 75 on 2017-10-19

Post score: 0


Original comments

Comment by gvdhoorn on 2017-10-19:\

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.

Comment by Long Smith on 2017-10-19:
@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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by gvdhoorn with karma: 86574 on 2017-10-19

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Long Smith on 2017-10-19:
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).

Comment by Long Smith on 2017-10-19:
Whatsoever it was, now, thanks to your answer, it works.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.