Cheetah Software  1.0
HardwareBridge.h
Go to the documentation of this file.
1 
9 #ifndef PROJECT_HARDWAREBRIDGE_H
10 #define PROJECT_HARDWAREBRIDGE_H
11 
12 #define MAX_STACK_SIZE 16384 // 16KB of stack
13 #define TASK_PRIORITY 49 // linux priority, this is not the nice value
14 
15 #include <lcm-cpp.hpp>
16 #include <string>
17 #include "RobotRunner.h"
18 #include "Utilities/PeriodicTask.h"
19 #include "control_parameter_request_lcmt.hpp"
20 #include "control_parameter_respones_lcmt.hpp"
21 #include "gamepad_lcmt.hpp"
22 
24  public:
26  : statusTask(&taskManager, 0.5f),
29  _robotRunner =
30  new RobotRunner(robot_ctrl, &taskManager, 0.001f, "robot-control");
32  }
33  void prefaultStack();
34  void setupScheduler();
35  void initError(const char* reason, bool printErrno = false);
36  void initCommon();
38  void handleGamepadLCM(const lcm::ReceiveBuffer* rbuf, const std::string& chan,
39  const gamepad_lcmt* msg);
40 
41  void handleInterfaceLCM();
42  void handleControlParameter(const lcm::ReceiveBuffer* rbuf,
43  const std::string& chan,
44  const control_parameter_request_lcmt* msg);
45 
47  void run_sbus();
48 
49  protected:
55  lcm::LCM _interfaceLCM;
57  control_parameter_respones_lcmt _parameter_response_lcmt;
60 
61  bool _firstRun = true;
65  std::thread _interfaceLcmThread;
66  volatile bool _interfaceLcmQuit = false;
68 
69  int _port;
70 };
71 
73  public:
75  void runSpi();
76  void initHardware();
77  void run();
78  void abort(const std::string& reason);
79  void abort(const char* reason);
80 
81  private:
83  lcm::LCM _spiLcm;
84 };
85 
86 #endif // PROJECT_HARDWAREBRIDGE_H
void handleInterfaceLCM()
control_parameter_respones_lcmt _parameter_response_lcmt
ControlParameters * _userControlParameters
void publishVisualizationLCM()
GamepadCommand _gamepadCommand
Implementation of a periodic function running in a separate thread. Periodic tasks have a task manage...
volatile bool _interfaceLcmQuit
lcm::LCM _interfaceLCM
SpiCommand _spiCommand
Common framework for running robot controllers. This code is a common interface between control code ...
VisualizationData _visualizationData
void handleControlParameter(const lcm::ReceiveBuffer *rbuf, const std::string &chan, const control_parameter_request_lcmt *msg)
std::string getLcmUrl(s64 ttl)
Definition: utilities.cpp:32
lcm::LCM _visualizationLCM
virtual ControlParameters * getUserControlParameters()=0
HardwareBridge(RobotController *robot_ctrl)
void initError(const char *reason, bool printErrno=false)
std::thread _interfaceLcmThread
uint64_t u64
Definition: cTypes.h:17
PrintTaskStatus statusTask
VectorNavData _vectorNavData
PeriodicTaskManager taskManager
RobotControlParameters _robotParams
void handleGamepadLCM(const lcm::ReceiveBuffer *rbuf, const std::string &chan, const gamepad_lcmt *msg)
RobotRunner * _robotRunner
CheetahVisualization _mainCheetahVisualization
MX f(const MX &x, const MX &u)