22 #include "MASurfaceAnalyzer.hpp" 24 #include "core/MAContainerStatistics.hpp" 25 #include "types/MABodyMotion.hpp" 26 #include "types/MARobotState.hpp" 27 #include "types/MATorso.hpp" 29 #include <MCSampleStatistics.hpp> 31 #include <libxtract.h> 34 SampleSize(sample_size < 4 ? 4 : sample_size),
35 IrSampleSize(sample_size < 112 ? 112 : (sample_size+sample_size % 2)),
36 AccelXSamples(SampleSize, *new
MCMedian<double>(
"Median")),
37 AccelYSamples(SampleSize, *new
MCMedian<double>(
"Median")),
38 AccelZSamples(SampleSize, *new
MCMedian<double>(
"Median")),
131 return MC::FloatList();
133 MC::FloatList Features;
134 MC::FloatTable FFTComponents;
135 double UserData[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
137 double RmsAmplitude = 0;
141 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelXMedian")
143 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelXMax")
147 Features.push_back((
float)Skewness);
148 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelXSkewness")
150 Features.push_back((
float)RmsAmplitude);
151 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelXRmsAmplitude")
155 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelYMedian")
157 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelYMaximum")
161 Features.push_back((
float)Skewness);
162 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelYSkewness")
164 Features.push_back((
float)RmsAmplitude);
165 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelYRmsAmplitude")
169 Features.push_back((
float)FFTComponents[0][0]);
170 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZFft0")
171 Features.push_back((
float)FFTComponents[0][1]);
172 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZFft1")
173 Features.push_back((
float)FFTComponents[0][2]);
174 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZFft2")
175 Features.push_back((
float)FFTComponents[0][5]);
176 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZFft5")
177 Features.push_back((
float)FFTComponents[0][8]);
178 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZFft8")
179 Features.push_back((
float)FFTComponents[0][11]);
180 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZFft11")
182 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZMedian")
184 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZMaximum")
188 Features.push_back((
float)Skewness);
189 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZSkewness")
191 Features.push_back((
float)RmsAmplitude);
192 MA_ANALYZER_ADD_FEATURE_NAME(
"AccelZRmsAmplitude")
196 MA_ANALYZER_ADD_FEATURE_NAME(
"PawLFSum")
198 MA_ANALYZER_ADD_FEATURE_NAME(
"PawLHSum")
200 MA_ANALYZER_ADD_FEATURE_NAME(
"PawRFSum")
202 MA_ANALYZER_ADD_FEATURE_NAME(
"PawRHSum")
206 for (
int i = 0; i < 5; ++i)
208 Features.push_back(FFTComponents[0][i]);
210 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestFft0")
211 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestFft1")
212 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestFft2")
213 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestFft3")
214 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestFft4")
216 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestFftMax")
218 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestIqr")
220 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestMax")
224 Features.push_back((
float)Skewness);
225 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestSkewness")
227 Features.push_back((
float)RmsAmplitude);
228 MA_ANALYZER_ADD_FEATURE_NAME(
"IrChestRmsAmplitude")
232 for (
int i = 0; i < 3; ++i)
234 Features.push_back(FFTComponents[0][i]);
236 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceFft0")
237 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceFft1")
238 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceFft2")
240 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceFftMax")
242 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceIqr")
244 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceMax")
248 Features.push_back((
float)Skewness);
249 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceSkewness")
251 Features.push_back((
float)RmsAmplitude);
252 MA_ANALYZER_ADD_FEATURE_NAME(
"LegLHJ1ForceRmsAmplitude")
256 for (
int i = 0; i < 3; ++i)
258 Features.push_back(FFTComponents[0][i]);
260 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceFft0")
261 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceFft1")
262 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceFft2")
264 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceFftMax")
266 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceIqr")
268 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceMax")
272 Features.push_back((
float)Skewness);
273 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceSkewness")
275 Features.push_back((
float)RmsAmplitude);
276 MA_ANALYZER_ADD_FEATURE_NAME(
"LegRHJ1ForceRmsAmplitude")
277 MA_ANALYZER_FEATURE_NAMES_COMMIT(Features);
Arithmetic sum statistic.
MCSamples< double > LegRHJ1ForceSamples
Force samples (RH/joint1)
int GetSampleCount() const
Get the sample count in the cache.
int IrSampleSize
Infrared sample size.
MC::DoubleList IrChestRawSamples
Infrared (chest) raw samples.
MCSamples< double > PawLFSamples
Paw (LF) samples.
MCSamples< double > AccelYSamples
Accelerometer (y dimension) samples.
virtual void AddSamples(const MARobotState &robot_state) override
Add new samples from the robot state.
float MCCalculateVectorStatistic(const std::vector< T > &vector, MCSampleStatistic< T > &statistic)
Calculate a statistic over a vector.
MC::DoubleList AccelXRawSamples
Accelerometer X raw samples.
MC::DoubleList LegLHJ1ForceRawSamples
Force raw samples (LH/joint1)
MCSamples< double > IrChestSamples
Infrared (chest) samples.
virtual MC::FloatList GetFeatureVector() override
Get a feature vector.
boost::scoped_ptr< MALeg > LegRH
LegRH.
MASurfaceAnalyzer(int sample_size)
Class constructor.
MC::FloatTable MAFFTComponentsFromContainer(const U &container)
Calculate FFT components over a container.
virtual bool IsValid() const override
Check if enough samples were added to the analyzer.
MCSamples< double > PawRFSamples
Paw (RF) samples.
Interquartile range statistic.
MC::DoubleList AccelYRawSamples
Accelerometer Y raw samples.
bool IsValid() const
Check if the sample cache is valid for calculations.
MCSampleStatistic< T > * GetStatistic(const std::string &statistic_name)
Get a statistic by name.
virtual void Reset() override
Reset the analyzer and drop all samples.
boost::scoped_ptr< MABodyMotion > BodyMotion
Body motion.
boost::scoped_ptr< MALeg > LegLF
LegLF.
boost::scoped_ptr< MALeg > LegRF
LegRF.
MCSamples< double > AccelZSamples
Accelerometer (z dimension) samples.
int SampleSize
Sample size.
Standard deviation statistic.
MC::DoubleList AccelZRawSamples
Accelerometer Z raw samples.
MCSamples< double > PawLHSamples
Paw (LH) samples.
boost::scoped_ptr< MATorso > Torso
Torso.
boost::scoped_ptr< MALeg > LegLH
LegLH.
MCSamples< double > PawRHSamples
Paw (RH) samples.
MC::DoubleList LegRHJ1ForceRawSamples
Force raw samples (RH/joint1)
MCSamples< double > LegLHJ1ForceSamples
Force samples (LH/joint1)
MCSamples< double > AccelXSamples
Accelerometer (x dimension) samples.
Arithmetic mean statistic.
void Reset()
Get the size of the sample cache.
void AddStatistic(MCSampleStatistic< T > &statistic)
Add a statistic calculation.