Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.6
rev: v20.1.0
hooks:
- id: clang-format
types_or: []
Expand Down
68 changes: 39 additions & 29 deletions include/loik/ik-id-description-optimized.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ namespace loik
{
if (nj_ != nb_ + 1)
{
throw(std::runtime_error("[IkProblemFormulation::IkProblemFormulation]: nb does not equal "
"to nj - 1, robot model not supported !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::IkProblemFormulation]: nb does not equal "
"to nj - 1, robot model not supported !!!"));
}

if (eq_c_dim != 6)
{
throw(
std::runtime_error("[IkProblemFormulation::IkProblemFormulation]: equality constraint "
"dimension is not 6, problem formulation not supported !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::IkProblemFormulation]: equality constraint "
"dimension is not 6, problem formulation not supported !!!"));
}

H_refs_.reserve(static_cast<std::size_t>(nj));
Expand Down Expand Up @@ -112,8 +113,9 @@ namespace loik
H_refs.size() != static_cast<std::size_t>(nj_)
|| v_refs.size() != static_cast<std::size_t>(nj_))
{
throw(std::runtime_error("[IkProblemFormulation::UpdateReferences]: input arguments "
"'H_refs', 'v_refs' have wrong size!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateReferences]: input arguments "
"'H_refs', 'v_refs' have wrong size!!"));
}
H_refs_ = H_refs;
v_refs_ = v_refs;
Expand Down Expand Up @@ -144,8 +146,9 @@ namespace loik
// check constraint specification is consistant
if (!((active_task_constraint_ids.size() == Ais.size()) && ((Ais.size() == bis.size()))))
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraints]: "
"task_constraint_ids, Ais, and bis have different size !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraints]: "
"task_constraint_ids, Ais, and bis have different size !!!"));
}

// check constraint dimension is consistent between input arguments!
Expand All @@ -158,16 +161,18 @@ namespace loik
// check if number of equality constraints has changed
if (active_task_constraint_ids.size() != static_cast<std::size_t>(nc_eq_))
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraints]: number of equality "
"constraints doesn't match initialization!!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraints]: number of equality "
"constraints doesn't match initialization!!!"));
}

// check if equality constraint dim has changed
if (Ais[0].rows() != eq_c_dim_)
{
// TODO: need to check constraint dimension for each Ai and bi, not just the first ones
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraints]: equality constraint "
"dimension has changed!!! Updating constraint dimension"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraints]: equality constraint "
"dimension has changed!!! Updating constraint dimension"));
}

active_task_constraint_ids_ = active_task_constraint_ids;
Expand Down Expand Up @@ -206,8 +211,9 @@ namespace loik
// if 'c_id' not present in 'active_task_constraint_ids_', invoke 'AddEqConstraint()'
if (found_it == active_task_constraint_ids_.end())
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
}

// check if constraint dimension is consistent
Expand All @@ -224,9 +230,9 @@ namespace loik
// if 'c_id' appear more than once, then something went wrong, throw.
if (c_id_count > 1)
{
throw(
std::runtime_error("[IkProblemFormulation::UpdateEqConstraint]: multiple constraint "
"specification for the same link id, not supported, terminating !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraint]: multiple constraint "
"specification for the same link id, not supported, terminating !!!"));
}

// get index of 'c_id' in 'active_task_constraint_ids_'
Expand Down Expand Up @@ -261,8 +267,9 @@ namespace loik
// if 'c_id' not present in 'active_task_constraint_ids_', then throw
if (found_it == active_task_constraint_ids_.end())
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
}

// get index of 'c_id' in 'active_task_constraint_ids_'
Expand Down Expand Up @@ -293,14 +300,16 @@ namespace loik
// check constraint dimension
if (Ai.rows() != bi.rows())
{
throw(std::runtime_error("[IkProblemFormulation::AddEqConstraint]: input arguments "
"constraint dimension inconsistent !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::AddEqConstraint]: input arguments "
"constraint dimension inconsistent !!!"));
}

if (Ai.rows() != static_cast<std::size_t>(eq_c_dim_))
{
throw(std::runtime_error("[IkProblemFormulation::AddEqConstraint]: input constraint "
"dimension differ from existing constriant dimension!!!"));
throw(std::runtime_error(
"[IkProblemFormulation::AddEqConstraint]: input constraint "
"dimension differ from existing constriant dimension!!!"));
}

active_task_constraint_ids_.push_back(c_id);
Expand Down Expand Up @@ -370,16 +379,17 @@ namespace loik
// check arguments have some dimension
if (lb.size() != ub.size())
{
throw(std::runtime_error("[IkProblemFormulation::UpdateIneqConstraints]: lower bound and "
"upper bound have different dimensions!!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateIneqConstraints]: lower bound and "
"upper bound have different dimensions!!!"));
}

// check is inequality constraint dimension has changed
if (lb.size() != ineq_c_dim_)
{
throw(
std::runtime_error("IkProblemFormulation::UpdateIneqConstraints]: inequality constraint "
"dimension has changed, this is not supported currently!!!"));
throw(std::runtime_error(
"IkProblemFormulation::UpdateIneqConstraints]: inequality constraint "
"dimension has changed, this is not supported currently!!!"));
}

lb_ = lb;
Expand Down
73 changes: 42 additions & 31 deletions include/loik/ik-id-description.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ namespace loik
{
if (nj_ != nb_ + 1)
{
throw(std::runtime_error("[IkProblemFormulation::IkProblemFormulation]: nb does not equal "
"to nj - 1, robot model not supported !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::IkProblemFormulation]: nb does not equal "
"to nj - 1, robot model not supported !!!"));
}

if (eq_c_dim != 6)
{
throw(
std::runtime_error("[IkProblemFormulation::IkProblemFormulation]: equality constraint "
"dimension is not 6, problem formulation not supported !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::IkProblemFormulation]: equality constraint "
"dimension is not 6, problem formulation not supported !!!"));
}

H_refs_.reserve(static_cast<std::size_t>(nj));
Expand Down Expand Up @@ -103,8 +104,9 @@ namespace loik
H_refs.size() != static_cast<std::size_t>(nj_)
|| v_refs.size() != static_cast<std::size_t>(nj_))
{
throw(std::runtime_error("[IkProblemFormulation::UpdateReferences]: input arguments "
"'H_refs', 'v_refs' have wrong size!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateReferences]: input arguments "
"'H_refs', 'v_refs' have wrong size!!"));
}
H_refs_ = H_refs;
v_refs_ = v_refs;
Expand All @@ -122,8 +124,9 @@ namespace loik
// check constraint specification is consistant
if (!((active_task_constraint_ids.size() == Ais.size()) && ((Ais.size() == bis.size()))))
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraints]: "
"task_constraint_ids, Ais, and bis have different size !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraints]: "
"task_constraint_ids, Ais, and bis have different size !!!"));
}

// check constraint dimension is consistent between input arguments!
Expand All @@ -136,16 +139,18 @@ namespace loik
// check if number of equality constraints has changed
if (active_task_constraint_ids.size() != static_cast<std::size_t>(nc_eq_))
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraints]: number of equality "
"constraints doesn't match initialization!!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraints]: number of equality "
"constraints doesn't match initialization!!!"));
}

// check if equality constraint dim has changed
if (Ais[0].rows() != eq_c_dim_)
{
// TODO: need to check constraint dimension for each Ai and bi, not just the first ones
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraints]: equality constraint "
"dimension has changed!!! Updating constraint dimension"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraints]: equality constraint "
"dimension has changed!!! Updating constraint dimension"));
}

active_task_constraint_ids_ = active_task_constraint_ids;
Expand All @@ -167,8 +172,9 @@ namespace loik
// if 'c_id' not present in 'active_task_constraint_ids_', invoke 'AddEqConstraint()'
if (found_it == active_task_constraint_ids_.end())
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
}

// check if constraint dimension is consistent
Expand All @@ -185,9 +191,9 @@ namespace loik
// if 'c_id' appear more than once, then something went wrong, throw.
if (c_id_count > 1)
{
throw(
std::runtime_error("[IkProblemFormulation::UpdateEqConstraint]: multiple constraint "
"specification for the same link id, not supported, terminating !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraint]: multiple constraint "
"specification for the same link id, not supported, terminating !!!"));
}

// get index of 'c_id' in 'active_task_constraint_ids_'
Expand All @@ -212,8 +218,9 @@ namespace loik
// if 'c_id' not present in 'active_task_constraint_ids_', then throw
if (found_it == active_task_constraint_ids_.end())
{
throw(std::runtime_error("[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateEqConstraint]: constraint doesn't "
"yet exist at link 'c_id' !!! "));
}

// get index of 'c_id' in 'active_task_constraint_ids_'
Expand Down Expand Up @@ -244,14 +251,16 @@ namespace loik
// check constraint dimension
if (Ai.rows() != bi.rows())
{
throw(std::runtime_error("[IkProblemFormulation::AddEqConstraint]: input arguments "
"constraint dimension inconsistent !!!"));
throw(std::runtime_error(
"[IkProblemFormulation::AddEqConstraint]: input arguments "
"constraint dimension inconsistent !!!"));
}

if (Ai.rows() != static_cast<std::size_t>(eq_c_dim_))
{
throw(std::runtime_error("[IkProblemFormulation::AddEqConstraint]: input constraint "
"dimension differ from existing constriant dimension!!!"));
throw(std::runtime_error(
"[IkProblemFormulation::AddEqConstraint]: input constraint "
"dimension differ from existing constriant dimension!!!"));
}

active_task_constraint_ids_.push_back(c_id);
Expand Down Expand Up @@ -297,16 +306,17 @@ namespace loik
// check arguments have some dimension
if (lb.size() != ub.size())
{
throw(std::runtime_error("[IkProblemFormulation::UpdateIneqConstraints]: lower bound and "
"upper bound have different dimensions!!!"));
throw(std::runtime_error(
"[IkProblemFormulation::UpdateIneqConstraints]: lower bound and "
"upper bound have different dimensions!!!"));
}

// check is inequality constraint dimension has changed
if (lb.size() != ineq_c_dim_)
{
throw(
std::runtime_error("IkProblemFormulation::UpdateIneqConstraints]: inequality constraint "
"dimension has changed, this is not supported currently!!!"));
throw(std::runtime_error(
"IkProblemFormulation::UpdateIneqConstraints]: inequality constraint "
"dimension has changed, this is not supported currently!!!"));
}

lb_ = lb;
Expand Down Expand Up @@ -521,8 +531,9 @@ namespace loik
}
else
{
throw(std::runtime_error("[IkProblemStandardQPFormulation::UpdateQPADMMSolveInit]: "
"parent id < 0, this can't happen !!!"));
throw(std::runtime_error(
"[IkProblemStandardQPFormulation::UpdateQPADMMSolveInit]: "
"parent id < 0, this can't happen !!!"));
}
}

Expand Down
5 changes: 3 additions & 2 deletions include/loik/loik-loid-optimized.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,9 @@ namespace loik
else if (this->mu_update_strat_ == ADMMPenaltyUpdateStrat::MAXEIGENVALUE)
{
// use max eigen value strategy
throw(std::runtime_error("[FirstOrderLoikOptimizedTpl::UpdateMu]: mu update strategy "
"MAXEIGENVALUE not yet implemented"));
throw(std::runtime_error(
"[FirstOrderLoikOptimizedTpl::UpdateMu]: mu update strategy "
"MAXEIGENVALUE not yet implemented"));
}
else
{
Expand Down
Loading