|
| 1 | +#! /usr/bin/env python |
| 2 | +#********************************************************************* |
| 3 | +#* Software License Agreement (BSD License) |
| 4 | +#* |
| 5 | +#* Copyright (c) 2017, Open Source Robotics Foundation |
| 6 | +#* All rights reserved. |
| 7 | +#* |
| 8 | +#* Redistribution and use in source and binary forms, with or without |
| 9 | +#* modification, are permitted provided that the following conditions |
| 10 | +#* are met: |
| 11 | +#* |
| 12 | +#* * Redistributions of source code must retain the above copyright |
| 13 | +#* notice, this list of conditions and the following disclaimer. |
| 14 | +#* * Redistributions in binary form must reproduce the above |
| 15 | +#* copyright notice, this list of conditions and the following |
| 16 | +#* disclaimer in the documentation and/or other materials provided |
| 17 | +#* with the distribution. |
| 18 | +#* * Neither the name of the Open Source Robotics Foundation |
| 19 | +#* nor the names of its contributors may be |
| 20 | +#* used to endorse or promote products derived |
| 21 | +#* from this software without specific prior written permission. |
| 22 | +#* |
| 23 | +#* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 24 | +#* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 25 | +#* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 26 | +#* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 27 | +#* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 28 | +#* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 29 | +#* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 30 | +#* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 31 | +#* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 32 | +#* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 33 | +#* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 34 | +#* POSSIBILITY OF SUCH DAMAGE. |
| 35 | +#*********************************************************************/ |
| 36 | + |
| 37 | +# Author: Aris Synodinos |
| 38 | +# Desc: Allows Lead Lag parameters, etc to be tuned in realtime using dynamic reconfigure |
| 39 | + |
| 40 | +PACKAGE='control_toolbox' |
| 41 | + |
| 42 | +def generate(gen): |
| 43 | + # Name Type Level Description Default Min Max |
| 44 | + gen.add( "k" , double_t, 1,"Gain.", 10.0 , -100000 , 100000) |
| 45 | + gen.add( "a" , double_t, 1,"Lead gain.", 0.1 , -1000 , 1000) |
| 46 | + gen.add( "b" , double_t, 1,"Lag gain.", 1.0 , -1000 , 1000) |
| 47 | + # PkgName #NodeName #Prefix for generated .h include file, e.g. ParametersConfig.py |
| 48 | + exit(gen.generate(PACKAGE, "control_toolbox", "LeadLag")) |
| 49 | + |
| 50 | +# try catkin generator first |
| 51 | +try: |
| 52 | + from dynamic_reconfigure.parameter_generator_catkin import * |
| 53 | + gen = ParameterGenerator() |
| 54 | + generate(gen) |
| 55 | +# reason for catching IndexError |
| 56 | +# parameter_generator_catkin expects 4 arguments while rosbuild only passes in 2 |
| 57 | +# not thrilled with this solution |
| 58 | +except IndexError: |
| 59 | + print 'ERROR', PACKAGE, 'Parameters.cfg failed using parameter_generator_catkin, using rosbuild instead' |
| 60 | + from dynamic_reconfigure.parameter_generator import * |
| 61 | + gen = ParameterGenerator() |
| 62 | + generate(gen) |
0 commit comments