change_ronex_configuration.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # ####################################################################
00004 # Copyright (c) 2013, Shadow Robot Company, All rights reserved.
00005 #
00006 # This library is free software; you can redistribute it and/or
00007 # modify it under the terms of the GNU Lesser General Public
00008 # License as published by the Free Software Foundation; either
00009 # version 3.0 of the License, or (at your option) any later version.
00010 #
00011 # This library is distributed in the hope that it will be useful,
00012 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014 # Lesser General Public License for more details.
00015 #
00016 # You should have received a copy of the GNU Lesser General Public
00017 # License along with this library.
00018 # ####################################################################
00019 
00020 import roslib
00021 import rospy
00022 import dynamic_reconfigure.client
00023 
00024 from time import sleep
00025 roslib.load_manifest('sr_ronex_examples')
00026 
00027 # --------------------------------------------------------------------------------
00028 
00029 """
00030 This class demonstrate how to change the configuration parameters of a running ronex module.
00031 """
00032 
00033 
00034 class ChangeRonexConfigurationExample(object):
00035 
00036     def __init__(self):
00037         # Define the ronex id of the module to be configured
00038         ronex_id = "test_ronex"
00039         ronex_path = "/ronex/general_io/" + ronex_id + "/"
00040         self.configure_ronex(ronex_path)
00041 
00042     def configure_ronex(self, path):
00043         """
00044         In this example we are using the dynamic_reconfigure.client.
00045         It could also be done by calling the /ronex/general_io/X/set_parameters service directly (as in the c++ example)
00046         """
00047         client = dynamic_reconfigure.client.Client(path)
00048 
00049         # calling update_configuration with a dictionary of changes to make
00050         params = {'input_mode_0': False, 'input_mode_1': False, 'pwm_period_0': 200, 'pwm_clock_divider': 3000}
00051         config = client.update_configuration(params)
00052 
00053         # config now contains the full configuration of the node after the parameter update
00054 
00055 
00056 # --------------------------------------------------------------------------------
00057 
00058 if __name__ == "__main__":
00059     rospy.init_node("change_ronex_configuration_py")
00060     ChangeRonexConfigurationExample()
00061 
00062 # --------------------------------------------------------------------------------


sr_ronex_examples
Author(s): Ugo Cupcic, Toni Oliver, Mark Pitchless, Yi Li
autogenerated on Thu Jun 6 2019 21:22:11