VehicleDifferential_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 <mvsim/World.h>
12 //#include <rapidxml.hpp>
13 
14 using namespace mvsim;
15 using namespace std;
16 
17 // See base class docs
21 {
22  co.wheel_torque_l = this->setpoint_wheel_torque_l;
23  co.wheel_torque_r = this->setpoint_wheel_torque_r;
24 }
25 
27  const TeleopInput& in, TeleopOutput& out)
28 {
29  ControllerBase::teleop_interface(in, out);
30 
31  switch (in.keycode)
32  {
33  case 'W':
34  case 'w':
35  setpoint_wheel_torque_l -= 0.5;
36  setpoint_wheel_torque_r -= 0.5;
37  break;
38 
39  case 'S':
40  case 's':
41  setpoint_wheel_torque_l += 0.5;
42  setpoint_wheel_torque_r += 0.5;
43  break;
44 
45  case 'A':
46  case 'a':
47  setpoint_wheel_torque_l += 0.5;
48  setpoint_wheel_torque_r -= 0.5;
49  break;
50 
51  case 'D':
52  case 'd':
53  setpoint_wheel_torque_l -= 0.5;
54  setpoint_wheel_torque_r += 0.5;
55  break;
56 
57  case ' ':
58  setpoint_wheel_torque_l = setpoint_wheel_torque_r = 0.0;
59  break;
60  };
61  out.append_gui_lines += "[Controller=" + string(class_name()) +
62  "] Teleop keys: w/s=incr/decr both torques. "
63  "a/d=left/right. spacebar=stop.\n";
64  out.append_gui_lines += mrpt::format(
65  "setpoint: tl=%.03f tr=%.03f deg\n", setpoint_wheel_torque_l,
66  setpoint_wheel_torque_r);
67 }
virtual void control_step(const DynamicsDifferential::TControllerInput &ci, DynamicsDifferential::TControllerOutput &co)
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out)


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