TestConfiguration.cpp
Go to the documentation of this file.
1 
7 #include <ros/ros.h>
8 #include <gtest/gtest.h>
9 
11 
12 namespace rokubimini
13 {
14 namespace configuration
15 {
16 class ConfigurationTest : public ::testing::Test
17 {
18 protected:
21  {
22  configuration = new Configuration();
23  }
24 
25  ~ConfigurationTest() override
26  {
27  delete configuration;
28  // You can do clean-up work that doesn't throw exceptions here.
29  }
30 
31  // If the constructor and destructor are not enough for setting up
32  // and cleaning up each test, you can define the following methods:
33 
34  void SetUp() override
35  {
36  // Code here will be called immediately after the constructor (right
37  // before each test).
38  }
39 
40  void TearDown() override
41  {
42  // Code here will be called immediately after each test (right
43  // before the destructor).
44  }
45 };
46 
47 TEST_F(ConfigurationTest, forceTorqueFilterWorksCorrectly)
48 {
49  configuration->setForceTorqueFilter(ForceTorqueFilter(64, true, true, false));
51  EXPECT_DOUBLE_EQ(filter.getSincFilterSize(), 64);
52  EXPECT_EQ(filter.getChopEnable(), true);
53  EXPECT_EQ(filter.getSkipEnable(), true);
54  EXPECT_EQ(filter.getFastEnable(), false);
55 }
56 
57 TEST_F(ConfigurationTest, forceTorqueOffsetWorksCorrectly)
58 {
59  configuration->setForceTorqueOffset(Eigen::Matrix<double, 6, 1>::Ones());
60  Eigen::Matrix<double, 6, 1> matrix = configuration->getForceTorqueOffset();
61  EXPECT_DOUBLE_EQ(matrix(0, 0), 1);
62  EXPECT_DOUBLE_EQ(matrix(1, 0), 1);
63  EXPECT_DOUBLE_EQ(matrix(2, 0), 1);
64  EXPECT_DOUBLE_EQ(matrix(3, 0), 1);
65  EXPECT_DOUBLE_EQ(matrix(4, 0), 1);
66  EXPECT_DOUBLE_EQ(matrix(5, 0), 1);
67 }
68 
69 TEST_F(ConfigurationTest, useCustomCalibrationWorksCorrectly)
70 {
72  auto use_custom_calibration = configuration->getUseCustomCalibration();
73  EXPECT_EQ(use_custom_calibration, true);
74 }
75 
76 TEST_F(ConfigurationTest, setReadingToNanOnDisconnectWorksCorrectly)
77 {
79  auto set_reading_to_nan_on_disconnect = configuration->getSetReadingToNanOnDisconnect();
80  EXPECT_EQ(set_reading_to_nan_on_disconnect, true);
81 }
82 
83 TEST_F(ConfigurationTest, sensorConfigurationWorksCorrectly)
84 {
85  configuration->setSensorConfiguration(SensorConfiguration(true, true, false, false, false, true));
86  auto sensor_configuration = configuration->getSensorConfiguration();
87  EXPECT_EQ(sensor_configuration.getCalibrationMatrixActive(), true);
88  EXPECT_EQ(sensor_configuration.getTemperatureCompensationActive(), true);
89  EXPECT_EQ(sensor_configuration.getImuActive(), false);
90  EXPECT_EQ(sensor_configuration.getCoordinateSystemConfigurationActive(), false);
91  EXPECT_EQ(sensor_configuration.getInertiaCompensationActive(), false);
92  EXPECT_EQ(sensor_configuration.getOrientationEstimationActive(), true);
93 }
94 
95 TEST_F(ConfigurationTest, sensorCalibrationWorksCorrectly)
96 {
97  Eigen::Matrix<double, 6, 6> calibration_matrix = Eigen::Matrix<double, 6, 6>::Identity();
98  auto sensor_calibration = rokubimini::calibration::SensorCalibration();
99  sensor_calibration.setCalibrationMatrix(calibration_matrix);
100  configuration->setSensorCalibration(sensor_calibration);
101  auto calibration_expected = configuration->getSensorCalibration();
102  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(0, 0), 1);
103  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(0, 1), 0);
104  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(0, 2), 0);
105  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(0, 3), 0);
106  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(0, 4), 0);
107  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(0, 5), 0);
108 
109  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(1, 0), 0);
110  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(1, 1), 1);
111  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(1, 2), 0);
112  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(1, 3), 0);
113  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(1, 4), 0);
114  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(1, 5), 0);
115 
116  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(2, 0), 0);
117  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(2, 1), 0);
118  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(2, 2), 1);
119  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(2, 3), 0);
120  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(2, 4), 0);
121  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(2, 5), 0);
122 
123  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(3, 0), 0);
124  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(3, 1), 0);
125  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(3, 2), 0);
126  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(3, 3), 1);
127  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(3, 4), 0);
128  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(3, 5), 0);
129 
130  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(4, 0), 0);
131  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(4, 1), 0);
132  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(4, 2), 0);
133  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(4, 3), 0);
134  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(4, 4), 1);
135  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(4, 5), 0);
136 
137  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(5, 0), 0);
138  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(5, 1), 0);
139  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(5, 2), 0);
140  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(5, 3), 0);
141  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(5, 4), 0);
142  EXPECT_DOUBLE_EQ(calibration_expected.getCalibrationMatrix()(5, 5), 1);
143 }
144 
145 TEST_F(ConfigurationTest, imuAccelerationFilterWorksCorrectly)
146 {
147  configuration->setImuAccelerationFilter((unsigned int)128);
148  auto imu_acceleration_filter = configuration->getImuAccelerationFilter();
149  EXPECT_EQ(imu_acceleration_filter, (unsigned int)128);
150 }
151 
152 TEST_F(ConfigurationTest, imuAngularRateFilterWorksCorrectly)
153 {
154  configuration->setImuAngularRateFilter((unsigned int)128);
155  auto imu_angular_rate_filter = configuration->getImuAngularRateFilter();
156  EXPECT_EQ(imu_angular_rate_filter, (unsigned int)128);
157 }
158 
159 TEST_F(ConfigurationTest, imuAccelerationRangeWorksCorrectly)
160 {
162  auto imu_acceleration_range = configuration->getImuAccelerationRange();
163  EXPECT_EQ(imu_acceleration_range, 15);
164 }
165 
166 TEST_F(ConfigurationTest, imuAngularRateRangeWorksCorrectly)
167 {
169  auto imu_angular_rate_range = configuration->getImuAngularRateRange();
170  EXPECT_EQ(imu_angular_rate_range, 15);
171 }
172 
173 } // namespace configuration
174 } // namespace rokubimini
uint8_t getChopEnable() const
Gets the chopEnable variable.
void setUseCustomCalibration(const bool useCustomCalibration)
Sets the useCustomCalibration variable.
Class holding the force-torque filter settings.
bool getSetReadingToNanOnDisconnect() const
Gets the setReadingToNanOnDisconnect variable.
Class holding the configuration of the sensor.
const ForceTorqueFilter & getForceTorqueFilter() const
Gets the forceTorqueFilter variable.
void setImuAccelerationRange(const uint8_t imuAccelerationRange)
Sets the imuAccelerationRange variable.
void setImuAngularRateRange(const uint8_t imuAngularRateRange)
Sets the imuAngularRateRange variable.
void setSensorConfiguration(const SensorConfiguration &sensorConfiguration)
Sets the sensorConfiguration variable.
const Eigen::Matrix< double, 6, 1 > & getForceTorqueOffset() const
Gets the forceTorqueOffset variable.
bool getUseCustomCalibration() const
Gets the useCustomCalibration variable.
unsigned int getImuAngularRateFilter() const
Gets the imuAccelerationFilter variable.
Class holding the sensor configuration settings.
uint8_t getFastEnable() const
Gets the fastEnable variable.
The SensorCalibration class is used for holding the calibration information of each rokubi mini senso...
uint8_t getSkipEnable() const
Gets the skipEnable variable.
uint8_t getImuAccelerationRange() const
Gets the imuAccelerationRange variable.
void setForceTorqueFilter(const ForceTorqueFilter &forceTorqueFilter)
Sets the forceTorqueFilter variable.
void setImuAccelerationFilter(const unsigned int imuAccelerationFilter)
Sets the imuAccelerationFilter variable.
void setSetReadingToNanOnDisconnect(const bool setReadingToNanOnDisconnect)
Sets the setReadingToNanOnDisconnect variable.
const calibration::SensorCalibration & getSensorCalibration() const
Gets the sensorCalibration variable.
unsigned int getImuAccelerationFilter() const
uint8_t getImuAngularRateRange() const
Gets the imuAngularRateRange variable.
void setSensorCalibration(const calibration::SensorCalibration &sensorCalibration)
Sets the sensorCalibration variable.
uint16_t getSincFilterSize() const
Gets the sincFilterSize variable.
void setForceTorqueOffset(const Eigen::Matrix< double, 6, 1 > &forceTorqueOffset)
Sets the forceTorqueOffset variable.
TEST_F(ConfigurationTest, forceTorqueFilterWorksCorrectly)
void setImuAngularRateFilter(const unsigned int imuAngularRateFilter)
Sets the imuAngularRateFilter variable.
const SensorConfiguration & getSensorConfiguration() const
Gets the sensorConfiguration variable.
Tests Configuration.


rokubimini
Author(s):
autogenerated on Wed Mar 3 2021 03:09:12