45 const std::string& ns)
const
50 const std::string& ns)
56 if (x0.size() != environment.getController()->getStateDimension())
58 if (msg) *msg +=
"BenchmarkTaskVaryingInitialState: dimension mismatch between x0_default and controller.\n";
67 double x01_step =
_x01_n < 2 ? x01_dir : x01_dir / ((double)
_x01_n - 1);
69 double x02_step =
_x02_n < 2 ? x02_dir : x02_dir / ((double)
_x02_n - 1);
74 for (
int i = 0; i <
_x01_n; ++i)
78 for (
int j = 0; j <
_x02_n; ++j)
80 if (x0.size() > 1) x0[1] =
_x02_start + (
double)j * x02_step;
86 std::string ns_bench = ns +
"bench_" + std::to_string(idx) +
"/";
89 environment.getPlantPtr()->setState(x0);
92 _main_task->performTask(environment, signal_target, msg, ns_bench);
107 if (msg) *msg +=
"BenchmarkTaskVaryingInitialState(): no main task specified.\n";
111 if (!
_main_task->verify(environment, msg))
return false;
113 int dim_x = environment.getController()->getStateDimension();
117 *msg +=
"_x01_n > 0 required.\n";
121 if (
_x02_n <= 0 && dim_x < 2)
123 *msg +=
"_x01_n > 0 required if state dimension is > 1.\n";
129 *msg +=
"Dimension of x0_default does not match state dimension.\n";
141 #ifdef MESSAGE_SUPPORT
142 void BenchmarkTaskVaryingInitialState::toMessage(corbo::messages::BenchmarkTaskVaryingInitialState& message)
const
148 message.set_x01_n(
_x01_n);
152 message.set_x02_n(
_x02_n);
155 if (closed_loop_task)
156 closed_loop_task->toMessage(*message.mutable_closed_loop_control_task());
160 if (open_loop_task) open_loop_task->toMessage(*message.mutable_open_loop_control_task());
166 message.mutable_x0_default()->Resize(
_x0_default.size(),
false);
172 void BenchmarkTaskVaryingInitialState::fromMessage(
const corbo::messages::BenchmarkTaskVaryingInitialState& message, std::stringstream* issues)
174 switch (message.main_task_case())
176 case messages::BenchmarkTaskVaryingInitialState::kClosedLoopControlTask:
179 closed_loop_task->fromMessage(message.closed_loop_control_task(), issues);
183 case messages::BenchmarkTaskVaryingInitialState::kOpenLoopControlTask:
186 open_loop_task->fromMessage(message.open_loop_control_task(), issues);
193 if (issues) *issues <<
"BenchmarkTaskVaryingInitialState: selected task not implemented.\n";