VehicleAckermann_Drivetrain_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 
12 #include "xml_utils.h"
13 
14 using namespace mvsim;
15 using namespace std;
16 
19  : ControllerBase(veh), setpoint_wheel_torque(0), setpoint_steer_ang(0)
20 {
21 }
22 
23 // See base class docs
27 {
29  co.steer_ang = this->setpoint_steer_ang;
30 }
31 
33  const rapidxml::xml_node<char>& node)
34 {
36  params["torque"] = TParamEntry("%lf", &setpoint_wheel_torque);
37 
38  // Initial speed.
39  params["steer_ang_deg"] = TParamEntry("%lf_deg", &this->setpoint_steer_ang);
40 
41  parse_xmlnode_children_as_param(node, params);
42 }
43 
45  const TeleopInput& in, TeleopOutput& out)
46 {
48 
49  switch (in.keycode)
50  {
51  case 'W':
52  case 'w':
53  setpoint_wheel_torque -= 1.0;
54  break;
55 
56  case 'S':
57  case 's':
58  setpoint_wheel_torque += 1.0;
59  break;
60 
61  case 'A':
62  case 'a':
63  setpoint_steer_ang += 1.0 * M_PI / 180.0;
64  mrpt::keep_min(setpoint_steer_ang, m_veh.getMaxSteeringAngle());
65  break;
66 
67  case 'D':
68  case 'd':
69  setpoint_steer_ang -= 1.0 * M_PI / 180.0;
70  mrpt::keep_max(setpoint_steer_ang, -m_veh.getMaxSteeringAngle());
71  break;
72 
73  case ' ':
75  break;
76  };
77 
78  out.append_gui_lines += "[Controller=" + string(class_name()) +
79  "] Teleop keys: w/s=incr/decr torques. "
80  "a/d=left/right steering. spacebar=stop.\n";
82  "setpoint: t=%.03f steer=%.03f deg\n", setpoint_wheel_torque,
83  setpoint_steer_ang * 180.0 / M_PI);
84 }
std::map< std::string, TParamEntry > TParameterDefinitions
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
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
GLsizei const GLcharARB ** string
double steer_ang
Equivalent ackerman steering angle.
GLfloat * params
virtual void control_step(const DynamicsAckermannDrivetrain::TControllerInput &ci, DynamicsAckermannDrivetrain::TControllerOutput &co) override
virtual void load_config(const rapidxml::xml_node< char > &node) override


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