source: flair-src/trunk/lib/FlairIpc/src/IpcAhrsSensor.cpp@ 441

Last change on this file since 441 was 397, checked in by Sanahuja Guillaume, 4 years ago

add ipc lib

  • Property svn:eol-style set to native
File size: 1.8 KB
RevLine 
[397]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: 2021/03/03
6// filename: IpcAhrsSensor.cpp
7//
8// author: Sébastien Ambroziak
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class for a simulation ahrs
14//
15//
16/*********************************************************************/
17
18#include "IpcAhrsSensor.h"
19#include "ipc_receive.h"
20#include <FrameworkManager.h>
21#include <AhrsData.h>
22
23using std::string;
24using namespace flair::core;
25using namespace flair::sensor;
26
27namespace flair {
28namespace filter {
29
30IpcAhrsSensor::IpcAhrsSensor(string name, uint8_t priority, const char* ipc_name, int ipc_channel)
31 : Ahrs(nullptr, name), Thread(getFrameworkManager(), name, priority) {
32 receiver = new IpcReceiver<ipc::type::ahrs>(ipc_name,ipc_channel);
33 SetIsReady(true);
34}
35
36IpcAhrsSensor::~IpcAhrsSensor() {}
37// datas from SimulatedImu are AhrsData!
38void IpcAhrsSensor::Run(void) {
39 AhrsData *output;
40 GetDatas(&output);
41
42 while (!ToBeStopped()) {
43
44 Quaternion quaternion;
45 Vector3Df filteredAngRates;
46
47 receiver->receive();
48 quaternion.q0 = receiver->getValue().quaternion.w;
49 quaternion.q1 = receiver->getValue().quaternion.x;
50 quaternion.q2 = receiver->getValue().quaternion.y;
51 quaternion.q3 = receiver->getValue().quaternion.z;
52 filteredAngRates.x = receiver->getValue().angular_rate.x;
53 filteredAngRates.y = receiver->getValue().angular_rate.y;
54 filteredAngRates.z = receiver->getValue().angular_rate.z;
55
56 output->SetQuaternionAndAngularRates(quaternion, filteredAngRates);
57 output->SetDataTime(receiver->getTimestamp().toNanosec());
58
59 ProcessUpdate(output);
60 }
61}
62
63} // end namespace filter
64} // end namespace flair
Note: See TracBrowser for help on using the repository browser.