source: flair-src/branches/sanscv/lib/FlairSensorActuator/src/EmulatedController.h@ 342

Last change on this file since 342 was 324, checked in by Sanahuja Guillaume, 5 years ago

removing opencv dependency

File size: 2.5 KB
Line 
1// created: 2015/04/14
2// filename: EmulatedController.h
3//
4// author: Gildas Bayard
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: class that emulate a remote control.
10// Typical use case: run a demo without any reliable communication channel
11//
12//
13/*********************************************************************/
14
15#ifndef EMULATEDCONTROLLER_H
16#define EMULATEDCONTROLLER_H
17
18#include <TargetController.h>
19#include <list>
20
21namespace flair {
22 namespace core {
23 class Matrix;
24 }
25 namespace gui {
26 class Tab;
27 class TabWidget;
28 class DataPlot1D;
29 }
30}
31
32namespace flair { namespace sensor {
33 /*! \class EmulatedController
34 *
35 * \brief Emulated remote control
36 *
37 */
38 class EmulatedController : public TargetController {
39 public:
40 EmulatedController(std::string name,uint8_t priority=0);
41 ~EmulatedController();
42 enum class ButtonType : uint16_t {
43 start=0x0001,select=0x0002,square=0x0004,triangle=0x0008,
44 circle=0x0010,cross=0x0020,left1=0x0040,left2=0x0080,
45 left3=0x0100,right1=0x0200,right2=0x0400,right3=0x0800,
46 up=0x1000,down=0x2000,left=0x4000,right=0x8000
47 };
48 void AddStep(unsigned int durationMs,std::string description,uint16_t buttonPressed, float leftAxisX, float leftAxisY, float rightAxisX, float rightAxisY);
49 protected :
50 bool IsConnected() const;
51 //controller state stuff
52 bool ProcessMessage(core::Message *msg);
53 bool IsDataFrameReady();
54 void AcquireAxisData(core::Matrix &axis); //responsible for getting the axis data from the hardware
55 void AcquireButtonData(core::Matrix &button); //responsible for getting the button data from the hardware
56 bool ControllerInitialization();
57
58 private:
59 enum class DataType { axis,button };
60 void ComputeControllerData(DataType dataType, core::Matrix &data);
61 template<typename T> void fillVectorNoMutex(core::Matrix &vector,T data[],unsigned int size);
62 void fillVectorNoMutex(core::Matrix &destination,core::Matrix &source,unsigned int size);
63 struct StepData {
64 unsigned int durationMs; //milliseconds
65 core::Matrix *axisData;
66 core::Matrix *buttonData;
67 std::string description;
68 void Print();
69 };
70 std::list<StepData> steps;
71 };
72
73}}
74
75#endif // EMULATEDCONTROLLER_H
Note: See TracBrowser for help on using the repository browser.