iCub-main
eo_imu_privData.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  * Author: Valentina Gaggero
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef __eo_imu_privData_h__
10 #define __eo_imu_privData_h__
11 
13 #include <yarp/sig/Vector.h>
14 #include <mutex>
15 #include <map>
16 #include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
17 
18 
19 #include "serviceParser.h"
20 
21 
22 namespace yarp {
23  namespace dev {
24  class eo_imu_privData;
25  class PositionMaps;
26  class SensorsData;
27  }
28 }
29 
30 
31 class yarp::dev::PositionMaps // data used for handling the received messsages
32 {
33  std::uint8_t canpositionmap[eoas_sensors_numberof][eOcanports_number][16];
34  std::uint8_t ethpositionmap[eoas_sensors_numberof];
35 public:
36  PositionMaps();
37  ~PositionMaps();
38  bool init(servConfigImu_t &servCfg);
39  bool getIndex(const eOas_inertial3_data_t *data, uint8_t &index, eOas_sensor_t &type);
40  bool getIndex(eOas_sensor_t type, uint8_t canbus, uint8_t canaddress, uint8_t& index);
41  static bool getCanAddress(const eOas_inertial3_data_t *data, uint8_t &canbus, uint8_t &canaddress);
42 };
43 
44 
45 typedef struct
46 {
47  std::string name;
48  std::string framename;
49  yarp::sig::Vector values;
50  uint8_t state;
51  double timestamp;
52  double conversionFactor{1.0}; // raw to metric measure
53 } sensorInfo_t;
54 
56 {
57 private:
58  std::vector<std::vector<sensorInfo_t>> mysens;
59  mutable std::mutex mutex;
60  string errorstring;
61 
62 public:
63  SensorsData();
64  void init(servConfigImu_t &servCfg, string error_string);
65  bool update(eOas_sensor_t type, uint8_t index, eOas_inertial3_data_t *newdata);
66  bool updateStatus(eOas_sensor_t type, uint8_t index, eOas_inertial3_sensorstatus_t &status);
67  bool outOfRangeErrorHandler(const std::out_of_range& oor) const;
68 
69  size_t getNumOfSensors(eOas_sensor_t type) const;
70  uint8_t getSensorStatus(size_t sens_index, eOas_sensor_t type) const;
71  bool getSensorName(size_t sens_index, eOas_sensor_t type, std::string &name) const;
72  bool getSensorFrameName(size_t sens_index, eOas_sensor_t type, std::string &frameName) const;
73  bool getSensorMeasure(size_t sens_index, eOas_sensor_t type, yarp::sig::Vector& out, double& timestamp) const;
74 };
75 
76 
77 
78 
79 
80 
82 {
83 public:
86 
87  eo_imu_privData(std::string name);
89  bool fromConfig(yarp::os::Searchable &config, servConfigImu_t &servCfg);
90  bool sendConfing2board(servConfigImu_t &servCfg);
91  bool initRegulars(void);
92  yarp::dev::MAS_status sensorState_eo2yarp(eOas_sensor_t type, uint8_t eo_state);
93 
94  /* This function prints state of sensor when it is not ok:
95  * - for gyro, acc and mag: state=3 means taht the sensor is completely calibrated; if state is less than 3 than it has some calibration issues;
96  * - for "composed measure" they are completely calibarted if all tree sensors are calibrated, so they are completely calibrated if their state is 9 (3+3+3).
97  * For more information see IMUbosgh BNO055 data sheet page 68 */
98  void debugPrintStateNotOK(eOas_sensor_t type, uint8_t eo_state);
99 
100 };
101 
102 
103 
104 #endif //__eo_imu_privData_h__
@ data
bool init(servConfigImu_t &servCfg)
bool getIndex(const eOas_inertial3_data_t *data, uint8_t &index, eOas_sensor_t &type)
static bool getCanAddress(const eOas_inertial3_data_t *data, uint8_t &canbus, uint8_t &canaddress)
bool outOfRangeErrorHandler(const std::out_of_range &oor) const
void init(servConfigImu_t &servCfg, string error_string)
bool getSensorFrameName(size_t sens_index, eOas_sensor_t type, std::string &frameName) const
bool getSensorMeasure(size_t sens_index, eOas_sensor_t type, yarp::sig::Vector &out, double &timestamp) const
bool getSensorName(size_t sens_index, eOas_sensor_t type, std::string &name) const
bool updateStatus(eOas_sensor_t type, uint8_t index, eOas_inertial3_sensorstatus_t &status)
bool update(eOas_sensor_t type, uint8_t index, eOas_inertial3_data_t *newdata)
size_t getNumOfSensors(eOas_sensor_t type) const
uint8_t getSensorStatus(size_t sens_index, eOas_sensor_t type) const
yarp::dev::PositionMaps maps
void debugPrintStateNotOK(eOas_sensor_t type, uint8_t eo_state)
yarp::dev::MAS_status sensorState_eo2yarp(eOas_sensor_t type, uint8_t eo_state)
eo_imu_privData(std::string name)
bool fromConfig(yarp::os::Searchable &config, servConfigImu_t &servCfg)
yarp::dev::SensorsData sens
bool sendConfing2board(servConfigImu_t &servCfg)
Copyright (C) 2008 RobotCub Consortium.
out
Definition: sine.m:8
std::string framename
std::string name
yarp::sig::Vector values