Skip to content

Commit 71b360c

Browse files
erez-tomcopybara-github
authored andcommitted
Modifications to cube solving task:
- Switched from order 0 to order 1 splines. This makes the hand move more and avoids local minima. - Wait mode now adds joint velocity cost to prevent jittering. - Made the task harder: use default damping and armature, only frictionloss is reduced. - Add printouts from the cube task transitions. PiperOrigin-RevId: 602736932 Change-Id: I2bf3cbe9277c775361b8541415e53054b07b3c7d
1 parent 72b0df4 commit 71b360c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

mjpc/tasks/cube/cube_3x3x3.xml.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ diff --git a/cube_3x3x3_modified.xml b/cube_3x3x3_modified.xml
2323
<default class="cubelet">
2424
- <joint type="ball" armature="0.0001" damping="0.0005" frictionloss="0.001"/>
2525
- <geom type="mesh" condim="1" mesh="cubelet" euler="0 0 90"/>
26-
+ <joint type="ball" armature="0.00005" damping="0.0001" frictionloss="0.00005"/>
26+
+ <joint type="ball" armature="0.0001" damping="0.0005" frictionloss="0.00005"/>
2727
+ <geom type="mesh" condim="1" mesh="cubelet" quat="1 0 0 1"/>
2828
</default>
2929
<default class="core">

mjpc/tasks/cube/solve.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "mjpc/tasks/cube/solve.h"
1616

1717
#include <algorithm>
18+
#include <iostream>
1819
#include <random>
1920
#include <string>
2021

@@ -131,6 +132,7 @@ void CubeSolve::ResidualFn::Residual(const mjModel* model, const mjData* data,
131132
void CubeSolve::TransitionLocked(mjModel* model, mjData* data) {
132133
if (transition_model_) {
133134
if (mode == kModeWait) {
135+
weight[11] = .01; // add penalty on joint movement
134136
// wait
135137
} else if (mode == kModeScramble) { // scramble
136138
double scramble_param = parameters[6];
@@ -190,9 +192,11 @@ void CubeSolve::TransitionLocked(mjModel* model, mjData* data) {
190192

191193
// set face goal index
192194
goal_index_ = num_scramble - 1;
195+
std::cout << "rotations required: " << num_scramble << "\n";
193196

194197
// set to solve
195198
mode = kModeSolve;
199+
weight[11] = 0; // remove penalty on joint movement
196200
} else if (mode == kModeSolve) { // solve
197201
// set goal
198202
mju_copy(parameters.data(), goal_cache_.data() + 6 * goal_index_, 6);
@@ -204,7 +208,9 @@ void CubeSolve::TransitionLocked(mjModel* model, mjData* data) {
204208
if (mju_norm(error, 6) < 0.085) {
205209
if (goal_index_ == 0) {
206210
mode = kModeWait;
211+
std::cout << "solved!\n";
207212
} else {
213+
std::cout << "rotations remaining: " << goal_index_ << "\n";
208214
goal_index_--;
209215
}
210216
}
@@ -213,11 +219,10 @@ void CubeSolve::TransitionLocked(mjModel* model, mjData* data) {
213219

214220
// check for drop
215221
if (data->qpos[6] < kResetHeight) {
216-
// reset cube position + orientation
217-
mju_copy(data->qpos, model->key_qpos, 7);
222+
if (mode != kModeWait) { std::cout << "cube fell\n"; }
218223

219-
// reset cube velocity
220-
mju_zero(data->qvel, 6);
224+
// stop optimization
225+
mode = kModeWait;
221226
}
222227

223228
// check goal index

mjpc/tasks/cube/task.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<numeric name="agent_policy_width" data="0.0035" />
1313
<numeric name="sampling_spline_points" data="6" />
1414
<numeric name="sampling_exploration" data="0.1" />
15-
<numeric name="sampling_trajectories" data="20" />
16-
<numeric name="sampling_representation" data="0" />
15+
<numeric name="sampling_trajectories" data="60" />
16+
<numeric name="sampling_representation" data="1" />
1717
<!-- manual face goals -->
1818
<numeric name="residual_Red" data="0 -3.14 3.14"/>
1919
<numeric name="residual_Orange" data="0 -3.14 3.14"/>

0 commit comments

Comments
 (0)