source: flair-src/trunk/lib/FlairSensorActuator/src/EmulatedController.h@ 133

Last change on this file since 133 was 38, checked in by Bayard Gildas, 8 years ago

Modif. pour ajour manette émulée (EmulatedController)

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 FrameworkManager;
24 class cvmatrix;
25 }
26 namespace gui {
27 class Tab;
28 class TabWidget;
29 class DataPlot1D;
30 }
31}
32
33namespace flair { namespace sensor {
34 /*! \class EmulatedController
35 *
36 * \brief Emulated remote control
37 *
38 */
39 class EmulatedController : public TargetController {
40 public:
41 EmulatedController(const core::FrameworkManager* parent,std::string name,uint8_t priority=0);
42 ~EmulatedController();
43 enum class ButtonType : uint16_t {
44 start=0x0001,select=0x0002,square=0x0004,triangle=0x0008,
45 circle=0x0010,cross=0x0020,left1=0x0040,left2=0x0080,
46 left3=0x0100,right1=0x0200,right2=0x0400,right3=0x0800,
47 up=0x1000,down=0x2000,left=0x4000,right=0x8000
48 };
49 void AddStep(unsigned int durationMs,std::string description,uint16_t buttonPressed, float leftAxisX, float leftAxisY, float rightAxisX, float rightAxisY);
50 protected :
51 bool IsConnected() const;
52 //controller state stuff
53 bool ProcessMessage(core::Message *msg);
54 bool IsDataFrameReady();
55 void AcquireAxisData(core::cvmatrix &axis); //responsible for getting the axis data from the hardware
56 void AcquireButtonData(core::cvmatrix &button); //responsible for getting the button data from the hardware
57 bool ControllerInitialization();
58
59 private:
60 enum class DataType { axis,button };
61 void ComputeControllerData(DataType dataType, core::cvmatrix &data);
62 template<typename T> void fillVectorNoMutex(core::cvmatrix &vector,T data[],unsigned int size);
63 void fillVectorNoMutex(core::cvmatrix &destination,core::cvmatrix &source,unsigned int size);
64 struct StepData {
65 unsigned int durationMs; //milliseconds
66 core::cvmatrix *axisData;
67 core::cvmatrix *buttonData;
68 std::string description;
69 void Print();
70 };
71 std::list<StepData> steps;
72 };
73
74}}
75
76#endif // EMULATEDCONTROLLER_H
Note: See TracBrowser for help on using the repository browser.