VehicleAckermann_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 
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 {
38  std::map<std::string, TParamEntry> params;
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  keep_min(
71  setpoint_steer_ang, m_veh.getMaxSteeringAngle());
72  break;
73 
74  case 'D':
75  case 'd':
76  setpoint_steer_ang -= 1.0 * M_PI / 180.0;
77  keep_max(
78  setpoint_steer_ang, -m_veh.getMaxSteeringAngle());
79  break;
80 
81  case ' ':
84  break;
85  };
86  out.append_gui_lines += "[Controller=" + string(class_name()) +
87  "] Teleop keys: w/s=incr/decr torques. "
88  "a/d=left/right steering. spacebar=stop.\n";
89  out.append_gui_lines += mrpt::format(
90  "setpoint: t=%.03f steer=%.03f deg\n", setpoint_wheel_torque_l,
91  setpoint_steer_ang * 180.0 / M_PI);
92 }
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 control_step(const DynamicsAckermann::TControllerInput &ci, DynamicsAckermann::TControllerOutput &co)
virtual void load_config(const rapidxml::xml_node< char > &node)
double steer_ang
Equivalent ackerman steering angle.
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out)


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