12 #include <mrpt/math/TPoint2D.h>
13 #include <mvsim/PID_Controller.h>
14 #include <mvsim/PoseTrajectoryFollower.h>
15 #include <mvsim/VehicleBase.h>
41 WHEEL_CASTER_FRONT = 2,
52 ConfigPerWheel(
const std::string& _name,
const mrpt::math::TPoint2D& _pos)
53 : name(_name), pos(_pos)
58 mrpt::math::TPoint2D pos;
64 {
"l_wheel", {0.0, 0.5}},
65 {
"r_wheel", {0.0, -0.5}},
70 DynamicsDifferential(World* parent,
const std::vector<ConfigPerWheel>& cfgPerWheel);
84 double wheel_torque_l = 0;
85 double wheel_torque_r = 0;
100 double setpoint_wheel_torque_l = 0, setpoint_wheel_torque_r = 0;
102 double setpoint_teleop_steps = 5e-2;
104 virtual void control_step(
116 static const char* class_name() {
return "twist_pid"; }
118 virtual void control_step(
126 double KP = 10, KI = 0, KD = 0;
134 bool enable_antiwindup =
false;
152 bool setTwistCommand(
const mrpt::math::TTwist2D& t)
override
156 setpointMtx_.unlock();
165 setpointMtx_.unlock();
170 double distWheels_ = 0;
171 std::array<PID_Controller, 2> PIDs_;
172 mrpt::math::TTwist2D setpoint_{0, 0, 0};
173 mutable std::mutex setpointMtx_;
175 double joyMaxLinSpeed = 1.0;
176 double joyMaxAngSpeed = 0.5;
186 static const char* class_name() {
return "twist_ideal"; }
197 bool setTwistCommand(
const mrpt::math::TTwist2D& t)
override
201 setpointMtx_.unlock();
210 setpointMtx_.unlock();
215 double distWheels_ = 0;
216 mrpt::math::TTwist2D setpoint_{0, 0, 0};
217 mutable std::mutex setpointMtx_;
219 double joyMaxLinSpeed = 1.0;
220 double joyMaxAngSpeed = 0.5;
247 static const char* class_name() {
return "trajectory"; }
256 bool getTrajectoryPlotPoints(
257 std::vector<mrpt::math::TPoint2D>& pts,
double& height)
const override;
261 double vizHeight_ = 0.5;
264 const ControllerBase::Ptr& getController()
const {
return controller_; }
265 ControllerBase::Ptr& getController() {
return controller_; }
266 virtual ControllerBaseInterface* getControllerInterface()
override {
return controller_.get(); }
276 virtual std::vector<double> invoke_motor_controllers(
const TSimulContext& context)
override;
277 virtual void invoke_motor_controllers_post_step(
const TSimulContext& context)
override;
283 ControllerBase::Ptr controller_;
297 {
"l_wheel", {0.0, 0.5}},
298 {
"r_wheel", {0.0, -0.5}},
299 {
"caster_wheel", {0.5, 0.0}},
316 {
"lr_wheel", {0.0, 0.5}},
317 {
"rr_wheel", {0.0, -0.5}},
318 {
"lf_wheel", {0.5, 0.5}},
319 {
"rf_wheel", {0.5, -0.5}},
Definition: ControllerBase.h:77
Definition: VehicleDifferential.h:92
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
static const char * class_name()
Definition: VehicleDifferential.h:96
Definition: VehicleDifferential.h:244
Definition: VehicleDifferential.h:183
mrpt::math::TTwist2D setpoint() const
Definition: VehicleDifferential.h:206
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
Definition: VehicleDifferential.h:113
mrpt::math::TTwist2D setpoint() const
Definition: VehicleDifferential.h:161
bool enable_feedforward
Definition: VehicleDifferential.h:137
double KP
PID controller parameters.
Definition: VehicleDifferential.h:126
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
bool enable_reference_filter
Definition: VehicleDifferential.h:143
double N
Definition: VehicleDifferential.h:129
int reference_filter_order
Definition: VehicleDifferential.h:149
double reference_filter_tau
Definition: VehicleDifferential.h:146
double max_torque
Maximum abs. value torque (for clamp) [Nm].
Definition: VehicleDifferential.h:132
double feedforward_gain
Definition: VehicleDifferential.h:140
Definition: VehicleDifferential.h:290
Definition: VehicleDifferential.h:309
Definition: VehicleDifferential.h:32
ControllerBaseTempl< DynamicsDifferential > ControllerBase
Definition: VehicleDifferential.h:89
virtual mrpt::math::TTwist2D getVelocityLocalOdoEstimate() const override
virtual void dynamics_load_params_from_xml(const rapidxml::xml_node< char > *xml_node) override
const std::vector< ConfigPerWheel > configPerWheel_
Defined at ctor time:
Definition: VehicleDifferential.h:280
Definition: PoseTrajectoryFollower.h:38
Definition: VehicleBase.h:44
Definition: ControllerBase.h:34
Definition: VehicleDifferential.h:50
Definition: VehicleDifferential.h:81
Definition: basic_types.h:58