robot_controllers_python.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  *  Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2016, Fetch Robotics Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Unbounded Robotics nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 // Author: Derek King
00036 
00037 #include <boost/python.hpp>
00038 #include <robot_controllers/diff_drive_limiter.h>
00039 #include <robot_controllers_msgs/DiffDriveLimiterParams.h>
00040 
00041 namespace bp = boost::python;
00042 
00043 using robot_controllers::DiffDriveLimiter;
00044 using robot_controllers_msgs::DiffDriveLimiterParams;
00045 
00046 class pyDiffDriveLimiter : public DiffDriveLimiter
00047 {
00048 public:
00049   bp::tuple limit(double desired_linear_velocity,
00050                   double desired_angular_velocity,
00051                   double last_linear_velocity,
00052                   double last_angular_velocity,
00053                   double safety_scaling,
00054                   double dt)
00055   {
00056     double limited_linear_velocity, limited_angular_velocity;
00057     DiffDriveLimiter::limit(&limited_linear_velocity,
00058                                 &limited_angular_velocity,
00059                                 desired_linear_velocity,
00060                                 desired_angular_velocity,
00061                                 last_linear_velocity,
00062                                 last_angular_velocity,
00063                                 safety_scaling,
00064                                 dt);
00065     return bp::make_tuple(limited_linear_velocity, limited_angular_velocity);
00066   }
00067 
00068 
00069   bp::tuple calcWheelVelocities(double linear_velocity,
00070                                 double angular_velocity)
00071   {
00072     double left_velocity, right_velocity;
00073     DiffDriveLimiter::calcWheelVelocities(&left_velocity,
00074                                               &right_velocity,
00075                                               linear_velocity,
00076                                               angular_velocity);
00077     return bp::make_tuple(left_velocity, right_velocity);
00078   }
00079 };
00080 
00081 BOOST_PYTHON_MODULE(robot_controllers_python)
00082 {
00083   bp::class_<DiffDriveLimiterParams>("DiffDriveLimiterParams")
00084     .def_readwrite("max_linear_velocity", &DiffDriveLimiterParams::max_linear_velocity)
00085     .def_readwrite("max_linear_acceleration",
00086                    &DiffDriveLimiterParams::max_linear_acceleration)
00087     .def_readwrite("max_angular_velocity", &DiffDriveLimiterParams::max_angular_velocity)
00088     .def_readwrite("max_angular_acceleration",
00089                    &DiffDriveLimiterParams::max_angular_acceleration)
00090     .def_readwrite("max_wheel_velocity", &DiffDriveLimiterParams::max_wheel_velocity)
00091     .def_readwrite("track_width", &DiffDriveLimiterParams::track_width)
00092     .def_readwrite("angular_velocity_limits_linear_velocity",
00093                    &DiffDriveLimiterParams::angular_velocity_limits_linear_velocity)
00094     .def_readwrite("scale_to_wheel_velocity_limits",
00095                    &DiffDriveLimiterParams::scale_to_wheel_velocity_limits)
00096     ;
00097 
00098   bp::class_<pyDiffDriveLimiter>("DiffDriveLimiter")
00099     .def("limit", &pyDiffDriveLimiter::limit)
00100     .def("calcWheelVelocities", &pyDiffDriveLimiter::calcWheelVelocities)
00101     .add_property("params",
00102                   &pyDiffDriveLimiter::getParams,
00103                   &pyDiffDriveLimiter::setParams)
00104     .def("setParams", &pyDiffDriveLimiter::setParams)
00105     .def("getParams", &pyDiffDriveLimiter::getParams)
00106     .def("getDefaultParams", &pyDiffDriveLimiter::getDefaultParams)
00107     .staticmethod("getDefaultParams")
00108     .def("validateParams", &pyDiffDriveLimiter::validateParams)
00109     .staticmethod("validateParams")
00110     ;
00111 }


robot_controllers
Author(s): Michael Ferguson
autogenerated on Wed Jun 14 2017 04:09:10