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

How to call dynamic_reconfugure service of base_local_planner through code

asked 2016-11-21 08:46:36 -0600

FrankYou gravatar image

Hello everyone!

I want to modify the max_vel_x in base_local_planner_params.yaml at runtime. I followed the tutorial Dynamic Reconfigure Python Client to create a client :

#!/usr/bin/env python

PACKAGE = 'base_local_planner'
import roslib;roslib.load_manifest(PACKAGE)
import rospy

import dynamic_reconfigure.client

if __name__ == "__main__":
    rospy.init_node("blp_client")

    client = dynamic_reconfigure.client.Client("base_local_planner", timeout=4, config_callback=None)

    r = rospy.Rate(0.33)
    while not rospy.is_shutdown():
    client.update_configuration({"max_vel_x":0.06})
        r.sleep()

Then I ran roslaunch my_new_robot robot_config.launch; roslaunch my_new_robot move_base.launch; rosrun base_local_planner blp_client.py(since I was using navigation).

But errors were reported:

youjian@youjian-laptop:~$ rosrun base_local_planner blp_client.py
Traceback (most recent call last):
  File "/home/youjian/catkin_ws/src/base_local_planner/scripts/blp_client.py", line 16, in <module>
    client = dynamic_reconfigure.client.Client("base_local_planner", timeout=4, config_callback=callback)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/dynamic_reconfigure/client.py", line 84, in __init__
    self._set_service      = self._get_service_proxy('set_parameters', timeout)       
  File "/opt/ros/indigo/lib/python2.7/dist-packages/dynamic_reconfigure/client.py", line 305, in _get_service_proxy
    rospy.wait_for_service(service_name, timeout)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 143, in wait_for_service
    raise ROSException("timeout exceeded while waiting for service %s"%resolved_name)
rospy.exceptions.ROSException: timeout exceeded while waiting for service /base_local_planner/set_parameters

I dig into dynamic_reconfigure/src/dynamic_reconfigure/client.py:

line 65: @param name: name of the server to connect to (usually the node name)

So according to the error, it can't find a node called base_local_planner. Hence, I wonder if base_local_planner is a node,since I don't find ros::init(argc, argv, "base_local_planner") which indicates a node in any files in base_local_planner package. If base_local_planner is not a node, what should I give to the 1st paramenter of the function Client(), or is there another way to modify the max_vel_x at runtime through code not command and rqt_reconfigure gui.

The following is some codes relative to dynamic_reconfigure in base_local_planner/src/trajectory_planner_ros.cpp:

  dsrv_ = new dynamic_reconfigure::Server<BaseLocalPlannerConfig>(private_nh);
  dynamic_reconfigure::Server<BaseLocalPlannerConfig>::CallbackType cb = boost::bind(&TrajectoryPlannerROS::reconfigureCB, this, _1, _2);
  dsrv_->setCallback(cb);

thanks in advance!

edit retag flag offensive close merge delete

Comments

You can use rosnode list to view all the nodes running at a time. Alternatively you can look in your launch file to see what you have named it, but I'm guessing you are using something like move_base to spawn that node, in which case the name won't be listed.

shoemakerlevy9 gravatar image shoemakerlevy9  ( 2016-11-21 12:45:17 -0600 )edit

Hi, shoemakerlevy9. I have tried rosnode list, there is indeed not node called base_local_planner. As you said the base_local_planner was spawned by the move_base, in this case what should I give to the 1st parameter of the Clinet().thanks.

FrankYou gravatar image FrankYou  ( 2016-11-21 18:59:50 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-11-21 23:44:32 -0600

DavidN gravatar image

A base local planner is not a node, but it is a plug in used by move_base. So firstly, you need to know what "base local planner" is currently used by move_base by running rosparam get /move_base/base_local_planner . Normally the value could be base_local_planner/TrajectoryPlannerROS.

Assuming TrajectoryPlannerROS, in your Dynamic Reconfigure Client node, you have to specify:

client = dynamic_reconfigure.client.Client("move_base/TrajectoryPlannerROS", timeout=4, config_callback=None)

edit flag offensive delete link more

Comments

Hi, DavidN. I followed your instructions, replaced 1st param "base_local_planner" with "move_base/TrajectoryPlannerROS", but the same error appears:timeout exceeded while waiting for service /move_base/TrajectoryPlannerROS/set_parameters...

FrankYou gravatar image FrankYou  ( 2016-11-22 01:20:16 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-11-21 08:46:36 -0600

Seen: 2,980 times

Last updated: Nov 21 '16