source: flair-dev/trunk/include/FlairSensorActuator/EmulatedController.h@ 60

Last change on this file since 60 was 50, checked in by Sanahuja Guillaume, 8 years ago

doc

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 cvmatrix;
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::cvmatrix &axis); //responsible for getting the axis data from the hardware
55 void AcquireButtonData(core::cvmatrix &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::cvmatrix &data);
61 template<typename T> void fillVectorNoMutex(core::cvmatrix &vector,T data[],unsigned int size);
62 void fillVectorNoMutex(core::cvmatrix &destination,core::cvmatrix &source,unsigned int size);
63 struct StepData {
64 unsigned int durationMs; //milliseconds
65 core::cvmatrix *axisData;
66 core::cvmatrix *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.