robot_controllers_python.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2016, Fetch Robotics Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Unbounded Robotics nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 // Author: Derek King
36 
37 #include <boost/python.hpp>
38 #include <robot_controllers/diff_drive_limiter.h>
39 #include <robot_controllers_msgs/DiffDriveLimiterParams.h>
40 
41 namespace bp = boost::python;
42 
43 using robot_controllers::DiffDriveLimiter;
44 using robot_controllers_msgs::DiffDriveLimiterParams;
45 
46 class pyDiffDriveLimiter : public DiffDriveLimiter
47 {
48 public:
49  bp::tuple limit(double desired_linear_velocity,
50  double desired_angular_velocity,
51  double last_linear_velocity,
52  double last_angular_velocity,
53  double safety_scaling,
54  double dt)
55  {
56  double limited_linear_velocity, limited_angular_velocity;
57  DiffDriveLimiter::limit(&limited_linear_velocity,
58  &limited_angular_velocity,
59  desired_linear_velocity,
60  desired_angular_velocity,
61  last_linear_velocity,
62  last_angular_velocity,
63  safety_scaling,
64  dt);
65  return bp::make_tuple(limited_linear_velocity, limited_angular_velocity);
66  }
67 
68 
69  bp::tuple calcWheelVelocities(double linear_velocity,
70  double angular_velocity)
71  {
72  double left_velocity, right_velocity;
73  DiffDriveLimiter::calcWheelVelocities(&left_velocity,
74  &right_velocity,
75  linear_velocity,
76  angular_velocity);
77  return bp::make_tuple(left_velocity, right_velocity);
78  }
79 };
80 
81 BOOST_PYTHON_MODULE(robot_controllers_python)
82 {
83  bp::class_<DiffDriveLimiterParams>("DiffDriveLimiterParams")
84  .def_readwrite("max_linear_velocity", &DiffDriveLimiterParams::max_linear_velocity)
85  .def_readwrite("max_linear_acceleration",
86  &DiffDriveLimiterParams::max_linear_acceleration)
87  .def_readwrite("max_angular_velocity", &DiffDriveLimiterParams::max_angular_velocity)
88  .def_readwrite("max_angular_acceleration",
89  &DiffDriveLimiterParams::max_angular_acceleration)
90  .def_readwrite("max_wheel_velocity", &DiffDriveLimiterParams::max_wheel_velocity)
91  .def_readwrite("track_width", &DiffDriveLimiterParams::track_width)
92  .def_readwrite("angular_velocity_limits_linear_velocity",
93  &DiffDriveLimiterParams::angular_velocity_limits_linear_velocity)
94  .def_readwrite("scale_to_wheel_velocity_limits",
95  &DiffDriveLimiterParams::scale_to_wheel_velocity_limits)
96  ;
97 
98  bp::class_<pyDiffDriveLimiter>("DiffDriveLimiter")
99  .def("limit", &pyDiffDriveLimiter::limit)
100  .def("calcWheelVelocities", &pyDiffDriveLimiter::calcWheelVelocities)
101  .add_property("params",
102  &pyDiffDriveLimiter::getParams,
103  &pyDiffDriveLimiter::setParams)
104  .def("setParams", &pyDiffDriveLimiter::setParams)
105  .def("getParams", &pyDiffDriveLimiter::getParams)
106  .def("getDefaultParams", &pyDiffDriveLimiter::getDefaultParams)
107  .staticmethod("getDefaultParams")
108  .def("validateParams", &pyDiffDriveLimiter::validateParams)
109  .staticmethod("validateParams")
110  ;
111 }
bp::tuple calcWheelVelocities(double linear_velocity, double angular_velocity)
BOOST_PYTHON_MODULE(robot_controllers_python)
bp::tuple limit(double desired_linear_velocity, double desired_angular_velocity, double last_linear_velocity, double last_angular_velocity, double safety_scaling, double dt)


robot_controllers
Author(s): Michael Ferguson
autogenerated on Sun Sep 27 2020 03:22:39