35 #include <gtest/gtest.h> 37 #include <joint_states_settler/ConfigGoal.h> 44 static const unsigned int N = 9;
47 static const unsigned int C = 3;
50 static const char*
names[
C] = {
"A",
"B",
"C" };
53 static const double data[
N][
C] = { { 0, 0, 10},
64 static const unsigned int times[
N][2] = { { 0, 0 },
77 vector<calibration_msgs::Interval> intervals;
79 for (
unsigned int i=0; i<
N; i++)
81 sensor_msgs::JointStatePtr msg(
new sensor_msgs::JointState);
85 msg->position.resize(
C);
86 msg->velocity.resize(
C);
87 msg->effort.resize(
C);
89 for (
unsigned int j=0; j<
C; j++)
91 msg->name[j] =
names[j];
92 msg->position[j] =
data[i][j];
95 intervals.push_back(settler.
add(msg));
105 config.joint_names.clear();
106 config.joint_names.push_back(
"A");
107 config.joint_names.push_back(
"C");
109 config.tolerances.clear();
110 config.tolerances.push_back(2.5);
111 config.tolerances.push_back(100);
115 config.cache_size = 100;
124 config.joint_names.clear();
125 config.joint_names.push_back(
"A");
126 config.joint_names.push_back(
"B");
127 config.joint_names.push_back(
"C");
129 config.tolerances.clear();
130 config.tolerances.push_back(100);
131 config.tolerances.push_back(100);
132 config.tolerances.push_back(100);
136 config.cache_size = 100;
141 void doEasyCheck(
const vector<calibration_msgs::Interval>& intervals)
143 ASSERT_EQ(intervals.size(),
N);
144 EXPECT_EQ(intervals[0].
start.sec, (
unsigned int) 0);
145 EXPECT_EQ(intervals[0].end.sec, (
unsigned int) 0);
146 EXPECT_EQ(intervals[1].
start.sec, (
unsigned int) 0);
147 EXPECT_EQ(intervals[1].end.sec, (
unsigned int) 1);
148 EXPECT_EQ(intervals[2].
start.sec, (
unsigned int) 0);
149 EXPECT_EQ(intervals[2].end.sec, (
unsigned int) 2);
150 EXPECT_EQ(intervals[3].
start.sec, (
unsigned int) 1);
151 EXPECT_EQ(intervals[3].end.sec, (
unsigned int) 3);
152 EXPECT_EQ(intervals[4].
start.sec, (
unsigned int) 2);
153 EXPECT_EQ(intervals[4].end.sec, (
unsigned int) 4);
154 EXPECT_EQ(intervals[5].
start.sec, (
unsigned int) 2);
155 EXPECT_EQ(intervals[5].end.sec, (
unsigned int) 5);
156 EXPECT_EQ(intervals[6].
start.sec, (
unsigned int) 2);
157 EXPECT_EQ(intervals[6].end.sec, (
unsigned int) 6);
158 EXPECT_EQ(intervals[7].
start.sec, (
unsigned int) 5);
159 EXPECT_EQ(intervals[7].end.sec, (
unsigned int) 7);
160 EXPECT_EQ(intervals[8].
start.sec, (
unsigned int) 6);
161 EXPECT_EQ(intervals[8].end.sec, (
unsigned int) 8);
166 ASSERT_EQ(intervals.size(),
N);
167 EXPECT_EQ(intervals[0].
start.sec, (
unsigned int) 0);
168 EXPECT_EQ(intervals[0].end.sec, (
unsigned int) 0);
169 EXPECT_EQ(intervals[1].
start.sec, (
unsigned int) 0);
170 EXPECT_EQ(intervals[1].end.sec, (
unsigned int) 1);
171 EXPECT_EQ(intervals[2].
start.sec, (
unsigned int) 0);
172 EXPECT_EQ(intervals[2].end.sec, (
unsigned int) 2);
173 EXPECT_EQ(intervals[3].
start.sec, (
unsigned int) 0);
174 EXPECT_EQ(intervals[3].end.sec, (
unsigned int) 3);
175 EXPECT_EQ(intervals[4].
start.sec, (
unsigned int) 0);
176 EXPECT_EQ(intervals[4].end.sec, (
unsigned int) 4);
177 EXPECT_EQ(intervals[5].
start.sec, (
unsigned int) 15);
178 EXPECT_EQ(intervals[5].end.sec, (
unsigned int) 15);
179 EXPECT_EQ(intervals[6].
start.sec, (
unsigned int) 15);
180 EXPECT_EQ(intervals[6].end.sec, (
unsigned int) 16);
181 EXPECT_EQ(intervals[7].
start.sec, (
unsigned int) 15);
182 EXPECT_EQ(intervals[7].end.sec, (
unsigned int) 17);
183 EXPECT_EQ(intervals[8].
start.sec, (
unsigned int) 15);
184 EXPECT_EQ(intervals[8].end.sec, (
unsigned int) 18);
193 ASSERT_TRUE(config_result);
195 vector<calibration_msgs::Interval> intervals =
addToSettler(settler, 0);
205 ASSERT_TRUE(config_result);
207 vector<calibration_msgs::Interval> intervals =
addToSettler(settler, 1);
217 ASSERT_TRUE(config_result);
219 vector<calibration_msgs::Interval> intervals =
addToSettler(settler, 0);
224 ASSERT_TRUE(config_result);
232 int main(
int argc,
char **argv)
234 testing::InitGoogleTest(&argc, argv);
235 return RUN_ALL_TESTS();
void doMaxStepCheck(const vector< calibration_msgs::Interval > &intervals)
TEST(JointStatesSettler, easyCheck)
void doEasyCheck(const vector< calibration_msgs::Interval > &intervals)
bool configure(const joint_states_settler::ConfigGoal &goal)
calibration_msgs::Interval add(const sensor_msgs::JointStateConstPtr msg)
int main(int argc, char **argv)
static const unsigned int C
static const unsigned int times[N][2]
vector< calibration_msgs::Interval > addToSettler(JointStatesSettler &settler, unsigned int time_channel)
static const double data[N][C]
static const unsigned int N
static const char * names[C]