VehicleAckermann_Drivetrain_ControllerRaw.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014 Jose Luis Blanco Claraco (University of Almeria) |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under GNU General Public License version 3 |
7  | See <http://www.gnu.org/licenses/> |
8  +-------------------------------------------------------------------------+ */
9 
11 #include "xml_utils.h"
12 
13 using namespace mvsim;
14 using namespace std;
15 
18  : ControllerBase(veh), setpoint_wheel_torque(0), setpoint_steer_ang(0)
19 {
20  MRPT_TODO("I see this file!")
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 {
35  std::map<std::string, TParamEntry> params;
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  keep_min(
65  setpoint_steer_ang, m_veh.getMaxSteeringAngle());
66  break;
67 
68  case 'D':
69  case 'd':
70  setpoint_steer_ang -= 1.0 * M_PI / 180.0;
71  keep_max(
72  setpoint_steer_ang, -m_veh.getMaxSteeringAngle());
73  break;
74 
75  case ' ':
77  break;
78  };
79 
80  out.append_gui_lines += "[Controller=" + string(class_name()) +
81  "] Teleop keys: w/s=incr/decr torques. "
82  "a/d=left/right steering. spacebar=stop.\n";
83  out.append_gui_lines += mrpt::format(
84  "setpoint: t=%.03f steer=%.03f deg\n", setpoint_wheel_torque,
85  setpoint_steer_ang * 180.0 / M_PI);
86 }
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out) override
void parse_xmlnode_children_as_param(const rapidxml::xml_node< char > &xml_node, const std::map< std::string, TParamEntry > &params, const char *function_name_context="")
Definition: xml_utils.cpp:196
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out)
double steer_ang
Equivalent ackerman steering angle.
virtual void control_step(const DynamicsAckermannDrivetrain::TControllerInput &ci, DynamicsAckermannDrivetrain::TControllerOutput &co)


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 19:36:40