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!
↧