OrientedTactileSensorUnit.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdio.h>
4
5#include <fstream>
6#include <iostream>
7
8#include <netinet/in.h>
9
10#include <Eigen/Dense>
11
15
16#include <RobotAPI/interface/units/OrientedTactileSensorUnit.h>
17#include <RobotAPI/interface/units/UnitInterface.h>
18#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
20
21namespace armarx
22{
24 {
25 public:
28 {
29 defineOptionalProperty<std::string>("SerialInterfaceDevice",
30 "/dev/ttyACM0",
31 "The serial device the arduino is connected to.");
32
34 "TopicName",
35 "OrientedTactileSensorValues",
36 "Name of the topic on which the sensor values are provided");
37
39 "65524 3 12 65534 65534 1 1208 119 58726 1000 943 ",
40 "Sensor Register Data to calibrate the sensor");
41
43 "SamplesRotation", "20", "number of orientation values to differentiate");
44
46 "SamplesPressure", "10", "number of pressure values to differentiate");
47
49 "SamplesAcceleration", "20", "number of pressure values to differentiate");
50
51 defineOptionalProperty<bool>("logData", "false", "log data from sensor");
52 defineOptionalProperty<bool>("calibrateSensor",
53 "false"
54 "Set true to calibrate the sensor and get calibration "
55 "data and false to use existent calibration data");
57 "DebugDrawerTopicName",
58 "DebugDrawerUpdates",
59 "Name of the debug drawer topic that should be used");
60 }
61 };
62
63 /**
64 * @class OrientedTactileSensorUnit
65 * @brief ArmarX wrapper for an arduino due with one BNO055 IMU and one BMP280 pressure sensor
66 *
67 */
69 //TODO: needs interface to send calibration data
70 {
71 public:
73
74 std::string
75 getDefaultName() const override
76 {
77 return "OrientedTactileSensorUnit";
78 }
79
81 {
82 int id;
83 float pressure;
84 float qw, qx, qy, qz;
86 };
87
93
95 {
96 IceUtil::Time timestamp;
97 float pressure;
98 };
99
105
107 {
108 IceUtil::Time timestamp;
110 };
111
113 {
114 IceUtil::Time timestamp;
115 float accx, accy, accz;
116 };
117
118 protected:
119 void onInitComponent() override;
120 void onConnectComponent() override;
121
123
124 private:
125 std::ifstream arduinoIn;
126 std::ofstream arduinoOut;
128 OrientedTactileSensorUnitListenerPrx topicPrx;
129 OrientedTactileSensorUnitInterfacePrx interfacePrx;
130
131 void run();
132 SensorData getValues(std::string line);
133 bool getCalibrationValues(std::string line);
134 bool loadCalibration();
135 int fd;
136 CalibrationData calibration;
137
138 Eigen::Quaternionf inverseOrientation;
139 std::vector<RotationRate> samplesRotation;
140 std::vector<PressureRate> samplesPressure;
141 std::vector<AccelerationRate> samplesAcceleration;
142 std::vector<float> pressureRates;
143 //Eigen::AngleAxisf aa;
144 int maxSamplesRotation;
145 int sampleIndexRotation;
146 int maxSamplesPressure;
147 int sampleIndexPressure;
148 int maxSamplesAcceleration;
149 int sampleIndexAcceleration;
150 int sampleIndexPressureRate;
151 float sumPressureRates;
152 Eigen::Matrix3f sumOrientation;
153 bool first;
154 int i = 0;
155 DebugDrawerInterfacePrx debugDrawerTopic;
156 SimpleJsonLoggerPtr logger;
157 std::string prefix;
158 };
159} // namespace armarx
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
void onInitComponent() override
Pure virtual hook for the subclass.
void onConnectComponent() override
Pure virtual hook for the subclass.
PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getDefaultName() const override
Retrieve default name of component.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
Quaternion< float, 0 > Quaternionf
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
std::shared_ptr< SimpleJsonLogger > SimpleJsonLoggerPtr