美文网首页
04-Dynamic Reconfigure入门-python节

04-Dynamic Reconfigure入门-python节

作者: joey_zhou | 来源:发表于2016-12-12 12:10 被阅读80次

    编码

    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

    相关文章

      网友评论

          本文标题:04-Dynamic Reconfigure入门-python节

          本文链接:https://www.haomeiwen.com/subject/oqhndttx.html