[378] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %flair:license}
|
---|
| 5 | // created: 2020/&2/09
|
---|
| 6 | // filename: SumoUgvControls.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Class for a parrot sumo ugv controls
|
---|
| 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 | #ifdef CORE2_64
|
---|
| 18 |
|
---|
| 19 | #include "SumoUgvControls.h"
|
---|
| 20 | #include <Matrix.h>
|
---|
| 21 | #include <control.h>
|
---|
| 22 | #include <image.h>
|
---|
| 23 |
|
---|
| 24 | using std::string;
|
---|
| 25 | using namespace sumo;
|
---|
| 26 |
|
---|
| 27 | class ImageProcessing : public sumo::Image {
|
---|
| 28 | public:
|
---|
| 29 | void handleImage(const struct sumo::image *, const uint8_t *buffer, size_t size) {
|
---|
| 30 | //nothing to do in this demo
|
---|
| 31 | }
|
---|
| 32 | };
|
---|
| 33 |
|
---|
| 34 | namespace flair {
|
---|
| 35 | namespace actuator {
|
---|
| 36 |
|
---|
| 37 | SumoUgvControls::SumoUgvControls(string name)
|
---|
| 38 | : UgvControls(name) {
|
---|
| 39 |
|
---|
| 40 | sumoControl= new Control (new ImageProcessing);
|
---|
| 41 | if (!sumoControl->open()) {
|
---|
| 42 | Err("error opening sumo control\n");
|
---|
| 43 | } else {
|
---|
| 44 | SetIsReady(true);
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | SumoUgvControls::~SumoUgvControls() {
|
---|
| 49 | sumoControl->close();
|
---|
| 50 | delete sumoControl;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | void SumoUgvControls::SetControls(float speed,float turn) {
|
---|
| 55 | sumoControl->move(speed*127, turn*127);
|
---|
| 56 |
|
---|
| 57 | // on prend une fois pour toute le mutex et on fait des accès directs
|
---|
| 58 | output->GetMutex();
|
---|
| 59 | output->SetValueNoMutex(0, 0, speed);
|
---|
| 60 | output->SetValueNoMutex(1, 0, turn);
|
---|
| 61 | output->ReleaseMutex();
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | } // end namespace sensor
|
---|
| 66 | } // end namespace flair
|
---|
| 67 |
|
---|
| 68 | #endif |
---|