38 #include <exotica_core/planning_problem_initializer.h>
39 #include <exotica_core/task_map_initializer.h>
49 ret +=
"\n" + prepend +
" Task definitions:";
51 ret +=
"\n" + it.second->Print(prepend +
" ");
57 return scene_->get_num_positions();
62 return scene_->get_num_velocities();
67 return scene_->get_num_controls();
73 if (
scene_->GetDynamicsSolver() !=
nullptr)
75 const Eigen::VectorXd start_state =
scene_->GetDynamicsSolver()->GetPosition(
start_state_);
83 return scene_->GetControlledState();
88 for (
auto& it :
task_maps_) it.second->PreUpdate();
94 const auto num_states =
scene_->get_num_positions() +
scene_->get_num_velocities();
96 if (
x.rows() == num_states)
101 else if (
x.rows() ==
scene_->GetKinematicTree().GetNumControlledJoints())
103 auto jointNames =
scene_->GetControlledJointNames();
104 auto modelNames =
scene_->GetModelJointNames();
107 std::cout <<
"start_state_ size: " <<
start_state_.size() <<
"\n";
108 std::cout <<
"jointNames size: " << jointNames.size() <<
"\n";
109 std::cout <<
"modelNames size: " << modelNames.size() <<
"\n";
110 ThrowPretty(
"Ill-defined condition in PlanningProblem::SetStartState - throwing to avoid illegal memory access (broken logic)!");
113 for (
int i = 0; i < jointNames.size(); ++i)
115 for (
int j = 0; j < modelNames.size(); ++j)
122 else if (
x.rows() ==
scene_->get_num_positions())
129 ThrowNamed(
"Wrong start state vector size, expected " << num_states <<
", got " <<
x.rows());
151 PlanningProblemInitializer
init(init_in);
158 scene_->InstantiateInternal(SceneInitializer(
init.PlanningScene));
163 N =
scene_->GetKinematicTree().GetNumControlledJoints();
167 if (
init.StartState.rows() > 0)
171 if (
scene_->GetDynamicsSolver() !=
nullptr &&
173 scene_->GetDynamicsSolver()->get_num_state() ==
scene_->GetDynamicsSolver()->get_num_state_derivative() + 1)
183 switch (
init.DerivativeOrder)
209 new_map->AssignScene(
scene_);
210 new_map->ns_ =
ns_ +
"/" + new_map->GetObjectName();
213 ThrowNamed(
"Map '" + new_map->GetObjectName() +
"' already exists!");
215 std::vector<KinematicFrameRequest> frames = new_map->GetFrames();
217 for (
size_t i = 0; i < new_map->kinematics.size(); ++i)
221 request.
frames.insert(request.
frames.end(), frames.begin(), frames.end());
222 task_maps_[new_map->GetObjectName()] = new_map;
223 tasks_.push_back(new_map);
229 for (
int i = 0; i <
tasks_.size(); ++i)
234 tasks_[i]->start_jacobian = idJ;
235 tasks_[i]->length_jacobian =
tasks_[i]->TaskSpaceJacobianDim();
237 idJ +=
tasks_[i]->length_jacobian;
249 task->kinematics[0].Create(
response);
256 if (task->kinematics.size() > responses.size())
258 ThrowNamed(responses.size() <<
" responses provided but task " << task->GetObjectName() <<
" requires " << task->kinematics.size());
261 for (
size_t i = 0; i < task->kinematics.size(); ++i)
263 task->kinematics[i].Create(responses[i]);
285 std::pair<std::vector<double>, std::vector<double>> ret;
286 for (
size_t position = 0; position <
cost_evolution_.size(); ++position)
289 double time_point = std::chrono::duration_cast<std::chrono::duration<double>>(
cost_evolution_[position].first -
cost_evolution_[0].first).count();
290 ret.first.push_back(time_point);
307 else if (
index == -1)
320 cost_evolution_.assign(size, std::make_pair<std::chrono::high_resolution_clock::time_point, double>(std::chrono::high_resolution_clock::now(), std::numeric_limits<double>::quiet_NaN()));
330 else if (
index == -1)