Cheetah Software  1.0
MiniCheetahHardwareBridge Class Reference

#include <HardwareBridge.h>

+ Inheritance diagram for MiniCheetahHardwareBridge:
+ Collaboration diagram for MiniCheetahHardwareBridge:

Public Member Functions

 MiniCheetahHardwareBridge (RobotController *)
 
void runSpi ()
 
void initHardware ()
 
void run ()
 
void abort (const std::string &reason)
 
void abort (const char *reason)
 
- Public Member Functions inherited from HardwareBridge
 HardwareBridge (RobotController *robot_ctrl)
 
void prefaultStack ()
 
void setupScheduler ()
 
void initError (const char *reason, bool printErrno=false)
 
void initCommon ()
 
 ~HardwareBridge ()
 
void handleGamepadLCM (const lcm::ReceiveBuffer *rbuf, const std::string &chan, const gamepad_lcmt *msg)
 
void handleInterfaceLCM ()
 
void handleControlParameter (const lcm::ReceiveBuffer *rbuf, const std::string &chan, const control_parameter_request_lcmt *msg)
 
void publishVisualizationLCM ()
 
void run_sbus ()
 

Private Attributes

VectorNavData _vectorNavData
 
lcm::LCM _spiLcm
 

Additional Inherited Members

- Protected Attributes inherited from HardwareBridge
PeriodicTaskManager taskManager
 
PrintTaskStatus statusTask
 
GamepadCommand _gamepadCommand
 
VisualizationData _visualizationData
 
CheetahVisualization _mainCheetahVisualization
 
lcm::LCM _interfaceLCM
 
lcm::LCM _visualizationLCM
 
control_parameter_respones_lcmt _parameter_response_lcmt
 
SpiData _spiData
 
SpiCommand _spiCommand
 
bool _firstRun = true
 
RobotRunner_robotRunner = nullptr
 
RobotControlParameters _robotParams
 
u64 _iterations = 0
 
std::thread _interfaceLcmThread
 
volatile bool _interfaceLcmQuit = false
 
ControlParameters_userControlParameters = nullptr
 
int _port
 

Detailed Description

Definition at line 72 of file HardwareBridge.h.

Constructor & Destructor Documentation

MiniCheetahHardwareBridge::MiniCheetahHardwareBridge ( RobotController robot_ctrl)

Definition at line 201 of file HardwareBridge.cpp.

202  : HardwareBridge(robot_ctrl), _spiLcm(getLcmUrl(255)) {}
std::string getLcmUrl(s64 ttl)
Definition: utilities.cpp:32
HardwareBridge(RobotController *robot_ctrl)

Member Function Documentation

void MiniCheetahHardwareBridge::abort ( const std::string &  reason)
void MiniCheetahHardwareBridge::abort ( const char *  reason)
void MiniCheetahHardwareBridge::initHardware ( )

Definition at line 275 of file HardwareBridge.cpp.

References _vectorNavData, init_spi(), init_vectornav(), HardwareBridge::initError(), and VectorNavData::quat.

275  {
276  printf("[MiniCheetahHardware] Init vectornav\n");
277  _vectorNavData.quat << 1, 0, 0, 0;
279  initError("failed to initialize vectornav!\n", false);
280  }
281 
282  init_spi();
283 
284  // init spi
285  // init sbus
286  // init lidarlite
287 
288  // init LCM hardware logging thread
289 
290  //
291 }
bool init_vectornav(VectorNavData *vd_data)
void init_spi()
Definition: rt_spi.cpp:110
Quat< float > quat
Definition: IMUTypes.h:16
void initError(const char *reason, bool printErrno=false)
VectorNavData _vectorNavData

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MiniCheetahHardwareBridge::run ( )

Definition at line 204 of file HardwareBridge.cpp.

References HardwareBridge::_firstRun, HardwareBridge::_gamepadCommand, HardwareBridge::_mainCheetahVisualization, HardwareBridge::_port, HardwareBridge::_robotParams, HardwareBridge::_robotRunner, HardwareBridge::_spiCommand, HardwareBridge::_spiData, HardwareBridge::_userControlParameters, _vectorNavData, HardwareBridge::_visualizationData, RobotRunner::cheetahMainVisualization, RobotRunner::controlParameters, RobotRunner::driverCommand, RobotRunner::init(), init_sbus(), HardwareBridge::initCommon(), initHardware(), ControlParameters::isFullyInitialized(), MINI_CHEETAH, HardwareBridge::publishVisualizationLCM(), RobotRunner::robotType, HardwareBridge::run_sbus(), runSpi(), RobotRunner::spiCommand, RobotRunner::spiData, PeriodicTask::start(), HardwareBridge::statusTask, HardwareBridge::taskManager, RobotRunner::vectorNavData, and RobotRunner::visualizationData.

204  {
205  initCommon();
206  initHardware();
207 
208  //_robotRunner = new RobotRunner(&taskManager, 0.001f, "robot-control");
209 
218 
219  while (!_robotParams.isFullyInitialized()) {
220  printf("[Hardware Bridge] Waiting for robot parameters...\n");
221  usleep(1000000);
222  }
223 
226  printf("[Hardware Bridge] Waiting for user parameters...\n");
227  usleep(1000000);
228  }
229  }
230 
231  printf("[Hardware Bridge] Got all parameters, starting up!\n");
232 
233  _robotRunner->init();
234  _firstRun = false;
235 
236  // init control thread
237 
238  statusTask.start();
239 
240  // spi Task start
242  &taskManager, .002, "spi", &MiniCheetahHardwareBridge::runSpi, this);
243  spiTask.start();
244 
245  // robot controller start
246  _robotRunner->start();
247 
248  // visualization start
250  &taskManager, .0167, "lcm-vis",
252  visualizationLCMTask.start();
253 
254  // rc controller
255  _port = init_sbus(false); // Not Simulation
257  &taskManager, .005, "rc_controller", &HardwareBridge::run_sbus, this);
258  sbusTask.start();
259 
260  for (;;) {
261  usleep(1000000);
262  // printf("joy %f\n", _robotRunner->driverCommand->leftStickAnalog[0]);
263  }
264 }
SpiCommand * spiCommand
Definition: RobotRunner.h:51
SpiData * spiData
Definition: RobotRunner.h:50
ControlParameters * _userControlParameters
void publishVisualizationLCM()
GamepadCommand _gamepadCommand
VectorNavData * vectorNavData
Definition: RobotRunner.h:48
SpiCommand _spiCommand
VisualizationData _visualizationData
void init() override
Definition: RobotRunner.cpp:28
GamepadCommand * driverCommand
Definition: RobotRunner.h:46
CheetahVisualization * cheetahMainVisualization
Definition: RobotRunner.h:56
int init_sbus(int is_simulator)
Definition: rt_sbus.cpp:119
RobotControlParameters * controlParameters
Definition: RobotRunner.h:54
PrintTaskStatus statusTask
VectorNavData _vectorNavData
PeriodicTaskManager taskManager
VisualizationData * visualizationData
Definition: RobotRunner.h:55
RobotControlParameters _robotParams
RobotRunner * _robotRunner
CheetahVisualization _mainCheetahVisualization
RobotType robotType
Definition: RobotRunner.h:47

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void MiniCheetahHardwareBridge::runSpi ( )

Definition at line 293 of file HardwareBridge.cpp.

References HardwareBridge::_spiCommand, HardwareBridge::_spiData, _spiLcm, get_spi_command(), get_spi_data(), and spi_driver_run().

293  {
294  spi_command_t* cmd = get_spi_command();
295  spi_data_t* data = get_spi_data();
296 
297  memcpy(cmd, &_spiCommand, sizeof(spi_command_t));
298  spi_driver_run();
299  memcpy(&_spiData, data, sizeof(spi_data_t));
300 
301  _spiLcm.publish("spi_data", data);
302  _spiLcm.publish("spi_command", cmd);
303 }
SpiCommand _spiCommand
void spi_driver_run()
Definition: rt_spi.cpp:319
spi_data_t * get_spi_data()
Definition: rt_spi.cpp:337
spi_command_t * get_spi_command()
Definition: rt_spi.cpp:332

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

lcm::LCM MiniCheetahHardwareBridge::_spiLcm
private

Definition at line 83 of file HardwareBridge.h.

VectorNavData MiniCheetahHardwareBridge::_vectorNavData
private

Definition at line 82 of file HardwareBridge.h.


The documentation for this class was generated from the following files: