Skip to content

Commit

Permalink
increase kMaxCostTerms + add warning if exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
taylor committed Dec 12, 2022
1 parent b29816d commit 8827cb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mjpc/task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,16 @@ void Task::GetFrom(const mjModel* model) {
num_norm_parameters[num_norms]);
parameter_shift += num_norm_parameters[num_norms];
num_norms += 1;

// check for max norms
if (num_norms > kMaxCostTerms) {
mju_error("Number of cost terms exceeds maximum. Either: 1) reduce number of terms 2) increase kMaxCostTerms");
}
}
}



// set residual parameters
this->SetFeatureParameters(model);
}
Expand Down
2 changes: 1 addition & 1 deletion mjpc/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace mjpc {
inline constexpr double kRiskNeutralTolerance = 1.0e-6;

// maximum cost terms
inline constexpr int kMaxCostTerms = 10;
inline constexpr int kMaxCostTerms = 30;

using ResidualFunction = void(const double* parameters, const mjModel* model,
const mjData* data, double* residual);
Expand Down

0 comments on commit 8827cb3

Please sign in to comment.