Skip to content

Commit f5cb3aa

Browse files
committed
Merge remote-tracking branch 'upstream/main' into sample_gradient_v2
2 parents 7eaf68d + fd36cb8 commit f5cb3aa

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
$cmake_extra_args
6969
- name: Build MuJoCo MPC
7070
working-directory: build
71-
run: cmake --build . --config=Release ${{ matrix.cmake_build_args }} --target mjpc agent_test cost_derivatives_test norm_test rollout_test threadpool_test trajectory_test utilities_test direct_force_test direct_optimize_test direct_parameter_test direct_sensor_test direct_trajectory_test direct_utilities_test batch_filter_test batch_prior_test kalman_test unscented_test ${{ matrix.additional_targets }}
71+
run: cmake --build . --config=Release ${{ matrix.cmake_build_args }} --target mjpc agent_test agent_utilities_test cost_derivatives_test norm_test rollout_test threadpool_test trajectory_test direct_force_test direct_optimize_test direct_parameter_test direct_sensor_test direct_trajectory_test direct_utilities_test batch_filter_test batch_prior_test kalman_test unscented_test cubic_test gradient_planner_test gradient_test linear_test zero_test backward_pass_test ilqg_test robust_planner_test sampling_planner_test state_test task_test utilities_test ${{ matrix.additional_targets }}
7272
- name: Test MuJoCo MPC
7373
working-directory: build
7474
run: ctest -C Release --output-on-failure .

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

mjpc/planners/sampling/planner.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,10 @@ void SamplingPlanner::Plots(mjvFigure* fig_planner, mjvFigure* fig_timer,
432432

433433
// ----- timer ----- //
434434

435-
PlotUpdateData(
436-
fig_timer, timer_bounds, fig_timer->linedata[0 + timer_shift][0] + 1,
437-
1.0e-3 * noise_compute_time * planning, 100, 0 + timer_shift, 0, 1, -100);
435+
PlotUpdateData(fig_timer, timer_bounds,
436+
fig_timer->linedata[0 + timer_shift][0] + 1,
437+
1.0e-3 * noise_compute_time * planning, 100,
438+
0 + timer_shift, 0, 1, -100);
438439

439440
PlotUpdateData(fig_timer, timer_bounds,
440441
fig_timer->linedata[1 + timer_shift][0] + 1,

mjpc/tasks/cube/solve.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,17 @@ void CubeSolve::ResidualFn::Residual(const mjModel* model, const mjData* data,
109109
counter += 6;
110110

111111
// ---------- Residual (4) ----------
112+
113+
// The unmodified cube model has 20 ball joints: nq=86, nv=66.
114+
// The patch adds a free joint: nq=93, nv=72.
115+
// The task adds a ball joint: nq=97, nv=75.
116+
// The shadow hand has 24 DoFs: nq=121, nv=99.
117+
// The following two residuals apply for the last 24 entries of qpos and qvel:
112118
mju_sub(residual + counter, data->qpos + 97, model->key_qpos + 97, 24);
113119
counter += 24;
114120

115121
// ---------- Residual (5) ----------
116-
mju_copy(residual + counter, data->qvel + 97, 24);
122+
mju_copy(residual + counter, data->qvel + 75, 24);
117123
counter += 24;
118124

119125
// ---------- Residual (6) ----------

mjpc/test/agent/agent_utilities_test.cc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -234,25 +234,6 @@ TEST(AgentUtilitiesTest, Clamp) {
234234
EXPECT_NEAR(x[2], 0.0, 1.0e-5);
235235
}
236236

237-
TEST(AgentUtilitiesTest, PowerSequence) {
238-
// sequence
239-
double sequence[4] = {0.2, 0.3, 0.4, 0.5};
240-
int length = 4;
241-
double step = 0.1;
242-
243-
// power
244-
double power = 2.0;
245-
246-
// power sequence
247-
PowerSequence(sequence, step, sequence[0], sequence[3], power, length);
248-
249-
// test
250-
EXPECT_NEAR(sequence[0], 0.2, 1.0e-5);
251-
EXPECT_NEAR(sequence[1], 0.27142857, 1.0e-5);
252-
EXPECT_NEAR(sequence[2], 0.37142857, 1.0e-5);
253-
EXPECT_NEAR(sequence[3], 0.5, 1.0e-5);
254-
}
255-
256237
TEST(AgentUtilitiesTest, FindInterval) {
257238
// sequence
258239
std::vector<double> sequence{-1.0, 0.0, 1.0, 2.0};

0 commit comments

Comments
 (0)