VehicleAckermann_ControllerRaw.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2020 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
11 #include "xml_utils.h"
12 
13 using namespace mvsim;
14 using namespace std;
15 
17  DynamicsAckermann& veh)
18  : ControllerBase(veh),
19  setpoint_wheel_torque_l(0),
20  setpoint_wheel_torque_r(0),
21  setpoint_steer_ang(0)
22 {
23 }
24 
25 // See base class docs
29 {
32  co.steer_ang = this->setpoint_steer_ang;
33 }
34 
36  const rapidxml::xml_node<char>& node)
37 {
39  params["fl_torque"] = TParamEntry("%lf", &setpoint_wheel_torque_l);
40  params["fr_torque"] = TParamEntry("%lf", &setpoint_wheel_torque_r);
41 
42  // Initial speed.
43  params["steer_ang_deg"] = TParamEntry("%lf_deg", &this->setpoint_steer_ang);
44 
45  parse_xmlnode_children_as_param(node, params);
46 }
47 
49  const TeleopInput& in, TeleopOutput& out)
50 {
52 
53  switch (in.keycode)
54  {
55  case 'W':
56  case 'w':
59  break;
60 
61  case 'S':
62  case 's':
65  break;
66 
67  case 'A':
68  case 'a':
69  setpoint_steer_ang += 1.0 * M_PI / 180.0;
70  mrpt::keep_min(setpoint_steer_ang, m_veh.getMaxSteeringAngle());
71  break;
72 
73  case 'D':
74  case 'd':
75  setpoint_steer_ang -= 1.0 * M_PI / 180.0;
76  mrpt::keep_max(setpoint_steer_ang, -m_veh.getMaxSteeringAngle());
77  break;
78 
79  case ' ':
82  break;
83  };
84  out.append_gui_lines += "[Controller=" + string(class_name()) +
85  "] Teleop keys: w/s=incr/decr torques. "
86  "a/d=left/right steering. spacebar=stop.\n";
88  "setpoint: t=%.03f steer=%.03f deg\n", setpoint_wheel_torque_l,
89  setpoint_steer_ang * 180.0 / M_PI);
90 }
virtual void load_config(const rapidxml::xml_node< char > &node) override
std::map< std::string, TParamEntry > TParameterDefinitions
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
virtual void control_step(const DynamicsAckermann::TControllerInput &ci, DynamicsAckermann::TControllerOutput &co) override
void parse_xmlnode_children_as_param(const rapidxml::xml_node< char > &xml_node, const TParameterDefinitions &params, const std::map< std::string, std::string > &variableNamesValues={}, const char *functionNameContext="")
Definition: xml_utils.cpp:179
#define M_PI
GLuint in
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
GLsizei const GLcharARB ** string
double steer_ang
Equivalent ackerman steering angle.
GLfloat * params


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51