18 #include <gtest/gtest.h>
27 #define EPS_DISTANCE 0.01 // [m]
28 #define EPS_KAPPA 1e-6 // [1/m]
29 #define EPS_SIGMA 1e-6 // [1/m^2]
30 #define KAPPA 1.0 // [1/m]
31 #define DISCRETIZATION 0.05 // [m]
46 throw runtime_error(
"Test_HC_CC_State_Space.get_controls() not implemented");
51 return hc_cc_circle_param_;
57 double radius = hc_cc_circle_param.
radius;
58 double mu = hc_cc_circle_param.
mu;
59 double xc = radius * sin(mu);
60 double yc = radius * cos(mu);
64 goal.
x = xc + radius * sin(delta + mu);
65 goal.
y = yc - radius * cos(delta + mu);
73 double radius = hc_cc_circle_param.
radius;
74 double mu = hc_cc_circle_param.
mu;
75 double xc = radius * sin(mu);
76 double yc = radius * cos(mu);
81 goal.
x = xc + (1 /
kappa) * sin(delta);
82 goal.
y = yc - (1 /
kappa) * cos(delta);
90 double step = (stop -
start) /
static_cast<double>(num - 1);
91 vector<double> samples(num);
92 double sample =
start;
93 for (vector<double>::iterator iter = samples.begin(); iter != samples.end(); ++iter, sample +=
step)
100 return sqrt(pow(state2.
x - state1.
x, 2) + pow(state2.
y - state1.
y, 2));
105 double path_length = 0;
107 for (
const auto &state2 :
path)
128 for (
const auto &sigma :
sigmas)
136 for (
const auto &delta :
deltas)
142 vector<Control> reg_cc_controls;
144 vector<State> reg_cc_path = hc_cc_ss.
integrate(start_state, reg_cc_controls);
145 double reg_cc_path_length =
146 accumulate(reg_cc_controls.begin(), reg_cc_controls.end(), 0.0,
147 [](
double sum,
const Control &control) { return sum + fabs(control.delta_s); });
151 vector<Control> irreg_cc_controls;
152 cc_turn_controls(irreg_hc_cc_circle, cc_goal_config,
true, irreg_cc_controls);
153 vector<State> irreg_cc_path = hc_cc_ss.
integrate(start_state, irreg_cc_controls);
154 double irreg_cc_path_length =
155 accumulate(irreg_cc_controls.begin(), irreg_cc_controls.end(), 0.0,
156 [](
double sum,
const Control &control) { return sum + fabs(control.delta_s); });
163 vector<Control> reg_hc_controls;
165 vector<State> reg_hc_path = hc_cc_ss.
integrate(start_state, reg_hc_controls);
166 double reg_hc_path_length =
167 accumulate(reg_hc_controls.begin(), reg_hc_controls.end(), 0.0,
168 [](
double sum,
const Control &control) { return sum + fabs(control.delta_s); });
172 vector<Control> irreg_hc_controls;
173 hc_turn_controls(irreg_hc_cc_circle, hc_goal_config,
true, irreg_hc_controls);
174 vector<State> irreg_hc_path = hc_cc_ss.
integrate(start_state, irreg_hc_controls);
175 double irreg_hc_path_length =
176 accumulate(irreg_hc_controls.begin(), irreg_hc_controls.end(), 0.0,
177 [](
double sum,
const Control &control) { return sum + fabs(control.delta_s); });
192 for (
const auto &sigma :
sigmas)
200 for (
const auto &delta :
deltas)
205 cc_goal_state.
x = cc_goal_config.
x;
206 cc_goal_state.
y = cc_goal_config.
y;
209 cc_goal_state.
d = 0.0;
212 vector<Control> reg_cc_controls;
214 vector<State> reg_cc_path = hc_cc_ss.
integrate(start_state, reg_cc_controls);
218 vector<Control> irreg_cc_controls;
219 cc_turn_controls(irreg_hc_cc_circle, cc_goal_config,
true, irreg_cc_controls);
220 vector<State> irreg_cc_path = hc_cc_ss.
integrate(start_state, irreg_cc_controls);
226 hc_goal_state.
x = hc_goal_config.
x;
227 hc_goal_state.
y = hc_goal_config.
y;
230 hc_goal_state.
d = 0.0;
233 vector<Control> reg_hc_controls;
235 vector<State> reg_hc_path = hc_cc_ss.
integrate(start_state, reg_hc_controls);
239 vector<Control> irreg_hc_controls;
240 hc_turn_controls(irreg_hc_cc_circle, hc_goal_config,
true, irreg_hc_controls);
241 vector<State> irreg_hc_path = hc_cc_ss.
integrate(start_state, irreg_hc_controls);
249 for (
const auto &sigma :
sigmas)
255 for (
const auto &delta :
deltas)
260 goal_state.
x = goal_config.
x;
261 goal_state.
y = goal_config.
y;
266 vector<Control> cc_controls;
268 for (
const auto &cc_control : cc_controls)
269 EXPECT_LT(fabs(cc_control.sigma), sigma +
EPS_SIGMA);
283 for (
const auto &sigma :
sigmas)
289 for (
const auto &delta :
deltas)
294 goal_state.
x = goal_config.
x;
295 goal_state.
y = goal_config.
y;
300 vector<Control> cc_controls;
302 vector<State> cc_path = hc_cc_ss.
integrate(start_state, cc_controls);
303 for (
const auto &state : cc_path)
309 int main(
int argc,
char **argv)
311 testing::InitGoogleTest(&argc, argv);
312 return RUN_ALL_TESTS();