12 #include <mrpt/math/TPoint2D.h>
13 #include <mvsim/PID_Controller.h>
14 #include <mvsim/VehicleBase.h>
40 WHEEL_CASTER_FRONT = 2,
51 ConfigPerWheel(
const std::string& _name,
const mrpt::math::TPoint2D& _pos)
52 : name(_name), pos(_pos)
57 mrpt::math::TPoint2D pos;
63 {
"l_wheel", {0.0, 0.5}},
64 {
"r_wheel", {0.0, -0.5}},
69 DynamicsDifferential(World* parent,
const std::vector<ConfigPerWheel>& cfgPerWheel);
83 double wheel_torque_l = 0;
84 double wheel_torque_r = 0;
99 double setpoint_wheel_torque_l = 0, setpoint_wheel_torque_r = 0;
101 double setpoint_teleop_steps = 5e-2;
103 virtual void control_step(
115 static const char* class_name() {
return "twist_pid"; }
117 virtual void control_step(
125 double KP = 10, KI = 0, KD = 0;
133 bool enable_antiwindup =
false;
151 bool setTwistCommand(
const mrpt::math::TTwist2D& t)
override
155 setpointMtx_.unlock();
164 setpointMtx_.unlock();
169 double distWheels_ = 0;
170 std::array<PID_Controller, 2> PIDs_;
171 mrpt::math::TTwist2D setpoint_{0, 0, 0};
172 mutable std::mutex setpointMtx_;
174 double joyMaxLinSpeed = 1.0;
175 double joyMaxAngSpeed = 0.5;
185 static const char* class_name() {
return "twist_ideal"; }
195 bool setTwistCommand(
const mrpt::math::TTwist2D& t)
override
199 setpointMtx_.unlock();
208 setpointMtx_.unlock();
213 double distWheels_ = 0;
214 mrpt::math::TTwist2D setpoint_{0, 0, 0};
215 mutable std::mutex setpointMtx_;
217 double joyMaxLinSpeed = 1.0;
218 double joyMaxAngSpeed = 0.5;
221 const ControllerBase::Ptr& getController()
const {
return controller_; }
222 ControllerBase::Ptr& getController() {
return controller_; }
223 virtual ControllerBaseInterface* getControllerInterface()
override {
return controller_.get(); }
233 virtual std::vector<double> invoke_motor_controllers(
const TSimulContext& context)
override;
234 virtual void invoke_motor_controllers_post_step(
const TSimulContext& context)
override;
240 ControllerBase::Ptr controller_;
254 {
"l_wheel", {0.0, 0.5}},
255 {
"r_wheel", {0.0, -0.5}},
256 {
"caster_wheel", {0.5, 0.0}},
273 {
"lr_wheel", {0.0, 0.5}},
274 {
"rr_wheel", {0.0, -0.5}},
275 {
"lf_wheel", {0.5, 0.5}},
276 {
"rf_wheel", {0.5, -0.5}},
Definition: ControllerBase.h:60
Definition: VehicleDifferential.h:91
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
static const char * class_name()
Definition: VehicleDifferential.h:95
Definition: VehicleDifferential.h:182
mrpt::math::TTwist2D setpoint() const
Definition: VehicleDifferential.h:204
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
Definition: VehicleDifferential.h:112
mrpt::math::TTwist2D setpoint() const
Definition: VehicleDifferential.h:160
bool enable_feedforward
Definition: VehicleDifferential.h:136
double KP
PID controller parameters.
Definition: VehicleDifferential.h:125
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
bool enable_reference_filter
Definition: VehicleDifferential.h:142
double N
Definition: VehicleDifferential.h:128
int reference_filter_order
Definition: VehicleDifferential.h:148
double reference_filter_tau
Definition: VehicleDifferential.h:145
double max_torque
Maximum abs. value torque (for clamp) [Nm].
Definition: VehicleDifferential.h:131
double feedforward_gain
Definition: VehicleDifferential.h:139
Definition: VehicleDifferential.h:247
Definition: VehicleDifferential.h:266
Definition: VehicleDifferential.h:31
ControllerBaseTempl< DynamicsDifferential > ControllerBase
Definition: VehicleDifferential.h:88
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:237
Definition: VehicleBase.h:44
Definition: ControllerBase.h:34
Definition: VehicleDifferential.h:49
Definition: VehicleDifferential.h:80
Definition: basic_types.h:58