Skip to content

Commit a41fef3

Browse files
authored
Merge pull request #272 from thowell/ctrl_limit
Check model for missing actuator limits
2 parents 9e88726 + 9148d17 commit a41fef3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mjpc/agent.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ void Agent::Initialize(const mjModel* model) {
7373
if (model_) mj_deleteModel(model_);
7474
model_ = mj_copyModel(nullptr, model); // agent's copy of model
7575

76+
// check for limits on all actuators
77+
int num_missing = 0;
78+
for (int i = 0; i < model_->nu; i++) {
79+
if (!model_->actuator_ctrllimited[i]) {
80+
num_missing++;
81+
printf("%s (actuator %i) missing limits\n",
82+
model_->names + model_->name_actuatoradr[i], i);
83+
}
84+
}
85+
if (num_missing > 0) {
86+
mju_error("Ctrl limits required for all actuators.\n");
87+
}
88+
7689
// planner
7790
planner_ = GetNumberOrDefault(0, model, "agent_planner");
7891

0 commit comments

Comments
 (0)