Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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 }