ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
THANKS @gvdhoom!
i managed to get what i want using the dynamic_reconfigure!
General info: The config is a dictionary which stores the True/False value of the parameter. So by playing with it , you can control what you want to do!
#!/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):
global pub,tw,cw,global_name, client
print config
global_name = config['bool_param']
pub = rospy.Publisher('/turtle1/cmd_vel', Twist)
tw = Twist(Vector3(1,2,0), Vector3(0,0,1))
cw = Twist(Vector3(1,2,0),Vector3(0,0,-1))
if __name__ == "__main__":
rospy.init_node("dynamic_client")
rospy.wait_for_service("/dynamic_tutorials/set_parameters")
client = dynamic_reconfigure.client.Client("dynamic_tutorials", timeout=30, config_callback=callback)
r = rospy.Rate(1)
global_name = rospy.get_param("/dynamic_tutorials/bool_param")
while not rospy.is_shutdown():
if global_name:
pub.publish(tw)
else:
pub.publish(cw)
r.sleep()