Changeset 377 in flair-src for trunk/lib/FlairSensorActuator
- Timestamp:
- Dec 16, 2020, 9:40:44 AM (4 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.cpp
r376 r377 31 31 namespace actuator { 32 32 33 SimulatedUgvControls::SimulatedUgvControls( const IODevice *parent,string name, uint32_t modelId,uint32_t deviceId)34 : UgvControls( parent,name) {33 SimulatedUgvControls::SimulatedUgvControls(string name, uint32_t modelId,uint32_t deviceId) 34 : UgvControls(name) { 35 35 36 shmem = new SharedMem( (Thread *)this, ShMemName(modelId, deviceId),2 * sizeof(float)+sizeof(Time));36 shmem = new SharedMem(this, ShMemName(modelId, deviceId),2 * sizeof(float)+sizeof(Time)); 37 37 38 38 buf=(char*)malloc(2 * sizeof(float)+sizeof(Time)); … … 57 57 void SimulatedUgvControls::SetControls(float speed,float turn) { 58 58 float *values=(float*)buf; 59 buf[0]=speed;60 buf[1]=turn;59 values[0]=speed; 60 values[1]=turn; 61 61 Time time=GetTime(); 62 62 memcpy(buf+2 * sizeof(float),&time,sizeof(Time)); … … 67 67 output->GetMutex(); 68 68 for (int i = 0; i < 2; i++) { 69 output->SetValueNoMutex(i, 0, buf[i]);69 output->SetValueNoMutex(i, 0, values[i]); 70 70 } 71 71 output->ReleaseMutex(); -
trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.h
r376 r377 36 36 * Construct a SimulatedUgvControls. 37 37 * 38 * \param parent parent39 38 * \param name name 40 39 * \param modelId Model id 41 40 * \param deviceId Imu id of the Model 42 41 */ 43 SimulatedUgvControls( const core::IODevice *parent,std::string name,42 SimulatedUgvControls(std::string name, 44 43 uint32_t modelId,uint32_t deviceId); 45 44 … … 50 49 ~SimulatedUgvControls(); 51 50 52 private:53 54 51 /*! 55 52 * \brief Set controls values … … 61 58 */ 62 59 void SetControls(float speed,float turn); 60 private: 61 63 62 64 63 char *buf; -
trunk/lib/FlairSensorActuator/src/UgvControls.cpp
r376 r377 18 18 #include "UgvControls.h" 19 19 #include <Matrix.h> 20 #include <FrameworkManager.h> 21 #include <Tab.h> 22 #include <DataPlot1D.h> 20 23 21 24 using namespace flair::core; 25 using namespace flair::gui; 22 26 23 27 using std::string; … … 26 30 namespace actuator { 27 31 28 UgvControls::UgvControls(const IODevice *parent, string name) 29 : IODevice(parent, name) { 32 UgvControls::UgvControls(string name) 33 : IODevice(getFrameworkManager(), name) { 34 mainTab = new Tab(getFrameworkManager()->GetTabWidget(), name); 30 35 31 36 MatrixDescriptor *desc = new MatrixDescriptor(2, 1); … … 42 47 43 48 void UgvControls::UseDefaultPlot(void) { 44 49 DataPlot1D *speedPlot = new DataPlot1D(mainTab->NewRow(), "speed", -1, 1); 50 speedPlot->AddCurve(output->Element(0)); 51 DataPlot1D *turnPlot = new DataPlot1D(mainTab->LastRowLastCol(), "turn", -1, 1); 52 turnPlot->AddCurve(output->Element(1)); 45 53 } 46 54 -
trunk/lib/FlairSensorActuator/src/UgvControls.h
r376 r377 18 18 namespace flair { 19 19 namespace core { 20 class Matrix; 20 class Matrix; 21 } 22 namespace gui { 23 class Tab; 21 24 } 22 25 } … … 35 38 * \brief Constructor 36 39 * 37 * Construct a UgvControls. 40 * Construct a UgvControls. It will be child of the FrameworkManager. 38 41 * 39 * \param parent parent40 42 * \param name name 41 43 */ 42 UgvControls( const core::IODevice *parent,std::string name);44 UgvControls(std::string name); 43 45 44 46 /*! … … 63 65 core::Matrix *Output(void) const; 64 66 67 /*! 68 * \brief Set controls values 69 * 70 * \param speed speed value 71 * \param turn turn value 72 */ 73 virtual void SetControls(float speed,float turn)=0; 74 65 75 protected: 66 76 core::Matrix *output; … … 75 85 */ 76 86 void UpdateFrom(const core::io_data *data){}; 77 78 /*!79 * \brief Set controls values80 *81 * \param speed speed value82 * \param turn turn value83 */84 virtual void SetControls(float speed,float turn)=0;85 87 86 88 gui::Tab *mainTab; 87 89 }; 88 90 } // end namespace actuator
Note:
See TracChangeset
for help on using the changeset viewer.