04-Dynamic Reconfigure入门-python节

2016-12-12  本文已影响80人  joey_zhou

编码

vim nodes/client.py

#!/usr/bin/env python

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

import dynamic_reconfigure.client

def callback(config):
    rospy.loginfo("Config set to {int_param}, {double_param}, {str_param}, {bool_param}, {size}".format(**config))

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

    client = dynamic_reconfigure.client.Client("dynamic_tutorials", timeout=30, config_callback=callback)

    r = rospy.Rate(0.1)
    x = 0
    b = False
    while not rospy.is_shutdown():
    x = x+1
    if x>10:
        x=0
    b = not b
    client.update_configuration({"int_param":x, "double_param":(1/(x+1)), "str_param":str(rospy.get_rostime()), "bool_param":b, "size":1})
    r.sleep()

chmod +x nodes/client.py

运行程序

rosrun dynamic_tutorials server.py
rosrun rqt_gui rqt_gui -s reconfigure
rosrun dynamic_tutorials client.py

上一篇下一篇

猜你喜欢

热点阅读