Dynamic reconfigure
this is my client.py
#!/usr/bin/env python
PACKAGE = 'dynamic_tutorials'
import roslib;roslib.load_manifest(PACKAGE)
import rospy
import dynamic_reconfigure.client
from geometry_msgs.msg import Vector3, Twist
def callback(config):
rospy.loginfo("Config set to {bool_param}".format(**config))
if __name__ == "__main__":
rospy.init_node("dynamic_client")
pub = rospy.Publisher('/turtle1/cmd_vel', Twist)
rospy.wait_for_service("/dynamic_tutorials/set_parameters")
tw = Twist(Vector3(1,2,0), Vector3(0,0,1))
client = dynamic_reconfigure.client.Client("dynamic_tutorials", timeout=30, config_callback=callback)
r = rospy.Rate(1)
x = 0
b = True
while not rospy.is_shutdown():
x = x+1
if x >5:
pub.publish(tw)
x=0
client.update_configuration({"bool_param":b})
r.sleep()
When i run my server.py and client.py and turtlesim_node and dynamic_reconfigure, the turtle in the turtlesim node goes in circle every 5 seconds(regardless if the bool_param in dynamic reconfigure is ticked or unticked). If i click the bool_param, it becomes unticked immediately.
Intended action: When i click on a button(bool_param, in this case is ticked) in rqt_dynamic_reconfigure , it should publish the command and remain publishing the command untill i give further instructions.
How can i implement this action? I need to control the turtle movement using dynamic_reconfigure.
Thank you!
Can you clarify why you want to do this with
dynamic_reconfigure
?Basically I want an on/off button in my dynamic_reconfigure, to publish my customized data. So if the button is "on", it would publish the data.
Current problem : 1) the button in the dynamic configure does not have any effect on the turtle when turned "on" or "off".
That sounds like a strange thing to do with
dynamic_reconfigure
. More something for a service. Why do you feeldynamic_reconfigure
should be used for something like this?re: no effect: well, your callback doesn't do anything besides printing the
config
. It doesn't update anything.i need dynamic_reconfigure to able to change between modes for an autonomous vehicle, which is the ultimate goal. I am using turtlesim to find out how it can be done first.
Is it possible for you to guide me what i should have in my callback, to get the intended function? Any form of guide! :)
I still think this is not something you'd want to do with
dynamic_reconfigure
, but see amcl/src/amcl_node.cpp for how AMCL uses dyn rcfg. Mimic that in Python.