00001 00002 // Copyright (C) 2008-2009, Willow Garage, Inc. 00003 // 00004 // Redistribution and use in source and binary forms, with or without 00005 // modification, are permitted provided that the following conditions are met: 00006 // * Redistributions of source code must retain the above copyright notice, 00007 // this list of conditions and the following disclaimer. 00008 // * Redistributions in binary form must reproduce the above copyright 00009 // notice, this list of conditions and the following disclaimer in the 00010 // documentation and/or other materials provided with the distribution. 00011 // * Neither the name of Stanford University nor the names of its 00012 // contributors may be used to endorse or promote products derived from 00013 // this software without specific prior written permission. 00014 // 00015 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00016 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00017 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00018 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00019 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00020 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00021 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00024 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00025 // POSSIBILITY OF SUCH DAMAGE. 00027 00028 /* 00029 * Author: Stuart Glaser, Wim Meeussen 00030 */ 00031 00032 #ifndef MECHANISM_CONTROL_CONTROL_SPEC_H 00033 #define MECHANISM_CONTROL_CONTROL_SPEC_H 00034 00035 #pragma GCC diagnostic ignored "-Wextra" 00036 00037 #include <map> 00038 #include <string> 00039 #include <vector> 00040 #include <pr2_controller_interface/controller.h> 00041 #include <boost/circular_buffer.hpp> 00042 #include <boost/thread/mutex.hpp> 00043 #include <boost/accumulators/accumulators.hpp> 00044 #include <boost/accumulators/statistics/stats.hpp> 00045 #include <boost/accumulators/statistics/max.hpp> 00046 #include <boost/accumulators/statistics/mean.hpp> 00047 #include <boost/accumulators/statistics/variance.hpp> 00048 00049 typedef boost::accumulators::accumulator_set< 00050 double, boost::accumulators::stats<boost::accumulators::tag::max, 00051 boost::accumulators::tag::mean, 00052 boost::accumulators::tag::variance> > TimeStatistics; 00053 00054 struct Statistics { 00055 TimeStatistics acc; 00056 ros::Time time_last_control_loop_overrun; 00057 unsigned int num_control_loop_overruns; 00058 double max; 00059 boost::circular_buffer<double> max1; 00060 Statistics() : num_control_loop_overruns(0), max(0), max1(60) {} 00061 }; 00062 00063 struct ControllerSpec { 00064 std::string name; 00065 boost::shared_ptr<pr2_controller_interface::Controller> c; 00066 boost::shared_ptr<Statistics> stats; 00067 00068 ControllerSpec() : stats(new Statistics) {} 00069 ControllerSpec(const ControllerSpec &spec) 00070 : name(spec.name), c(spec.c), stats(spec.stats) {} 00071 }; 00072 00073 #endif 00074