Skip to content

Commit 12363a2

Browse files
erez-tomcopybara-github
authored andcommitted
Task name change: cube->rubik
PiperOrigin-RevId: 607648728 Change-Id: I1da4d4ef8ee62ad7b70de0ccef3a72f0e26a5d4a
1 parent 350f0c4 commit 12363a2

File tree

7 files changed

+40
-32
lines changed

7 files changed

+40
-32
lines changed

mjpc/tasks/CMakeLists.txt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ add_custom_target(
6868
COMMAND ${CMAKE_COMMAND} -E copy
6969
${menagerie_SOURCE_DIR}/wonik_allegro/right_hand.xml
7070
${CMAKE_CURRENT_BINARY_DIR}/allegro/right_hand.xml
71+
COMMAND ${CMAKE_COMMAND} -E copy_directory
72+
${menagerie_SOURCE_DIR}/shadow_hand/assets
73+
${CMAKE_CURRENT_BINARY_DIR}/shadow_reorient/assets
74+
7175
COMMAND ${CMAKE_COMMAND} -E copy_directory
7276
${menagerie_SOURCE_DIR}/wonik_allegro/assets
7377
${CMAKE_CURRENT_BINARY_DIR}/allegro/assets
7478
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/allegro/right_hand_modified.xml
7579
${CMAKE_CURRENT_BINARY_DIR}/allegro/right_hand.xml
7680
<${CMAKE_CURRENT_SOURCE_DIR}/allegro/right_hand.xml.patch
77-
COMMAND ${CMAKE_COMMAND} -E copy_directory
78-
${menagerie_SOURCE_DIR}/shadow_hand/assets
79-
${CMAKE_CURRENT_BINARY_DIR}/shadow_reorient/assets
81+
8082
COMMAND ${CMAKE_COMMAND} -E copy
8183
${menagerie_SOURCE_DIR}/franka_emika_panda/panda.xml
8284
${CMAKE_CURRENT_BINARY_DIR}/panda/panda.xml
@@ -86,6 +88,7 @@ add_custom_target(
8688
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/panda/panda_modified.xml
8789
${CMAKE_CURRENT_BINARY_DIR}/panda/panda.xml
8890
<${CMAKE_CURRENT_SOURCE_DIR}/panda/panda.xml.patch
91+
8992
COMMAND ${CMAKE_COMMAND} -E copy
9093
${menagerie_SOURCE_DIR}/unitree_a1/a1.xml
9194
${CMAKE_CURRENT_BINARY_DIR}/quadruped/a1.xml
@@ -95,12 +98,14 @@ add_custom_target(
9598
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/quadruped/a1_modified.xml
9699
${CMAKE_CURRENT_BINARY_DIR}/quadruped/a1.xml
97100
<${CMAKE_CURRENT_SOURCE_DIR}/quadruped/a1.xml.patch
101+
98102
COMMAND ${CMAKE_COMMAND} -E copy_directory
99103
${menagerie_SOURCE_DIR}/franka_emika_panda
100104
${CMAKE_CURRENT_BINARY_DIR}/manipulation
101105
COMMAND ${CMAKE_COMMAND} -E copy_directory
102106
${menagerie_SOURCE_DIR}/robotiq_2f85
103107
${CMAKE_CURRENT_BINARY_DIR}/manipulation
108+
104109
COMMAND ${CMAKE_COMMAND} -E copy
105110
${menagerie_SOURCE_DIR}/skydio_x2/x2.xml
106111
${CMAKE_CURRENT_BINARY_DIR}/quadrotor/quadrotor.xml
@@ -110,31 +115,32 @@ add_custom_target(
110115
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/quadrotor/quadrotor_modified.xml
111116
${CMAKE_CURRENT_BINARY_DIR}/quadrotor/quadrotor.xml
112117
<${CMAKE_CURRENT_SOURCE_DIR}/quadrotor/quadrotor.xml.patch
118+
113119
## Cube solve task
114120
# copy cube model from MuJoCo
115121
COMMAND ${CMAKE_COMMAND} -E copy
116122
${mujoco_SOURCE_DIR}/model/cube/cube_3x3x3.xml
117-
${CMAKE_CURRENT_BINARY_DIR}/cube/cube_3x3x3.xml
123+
${CMAKE_CURRENT_BINARY_DIR}/rubik/cube_3x3x3.xml
118124
# copy cube assets from MuJoCo
119125
COMMAND ${CMAKE_COMMAND} -E copy_directory
120126
${mujoco_SOURCE_DIR}/model/cube/assets
121-
${CMAKE_CURRENT_BINARY_DIR}/cube/assets
127+
${CMAKE_CURRENT_BINARY_DIR}/rubik/assets
122128
# modified cube model for task
123-
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/cube/cube_3x3x3_modified.xml
124-
${CMAKE_CURRENT_BINARY_DIR}/cube/cube_3x3x3.xml
125-
<${CMAKE_CURRENT_SOURCE_DIR}/cube/cube_3x3x3.xml.patch
129+
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/rubik/cube_3x3x3_modified.xml
130+
${CMAKE_CURRENT_BINARY_DIR}/rubik/cube_3x3x3.xml
131+
<${CMAKE_CURRENT_SOURCE_DIR}/rubik/cube_3x3x3.xml.patch
126132
# modified cube model to transition model for scramble mode
127-
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/cube/transition_model.xml
128-
${CMAKE_CURRENT_BINARY_DIR}/cube/cube_3x3x3.xml
129-
<${CMAKE_CURRENT_SOURCE_DIR}/cube/transition_model.xml.patch
133+
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/rubik/transition_model.xml
134+
${CMAKE_CURRENT_BINARY_DIR}/rubik/cube_3x3x3.xml
135+
<${CMAKE_CURRENT_SOURCE_DIR}/rubik/transition_model.xml.patch
130136
# copy hand model from Menagerie
131137
COMMAND ${CMAKE_COMMAND} -E copy
132138
${menagerie_SOURCE_DIR}/shadow_hand/right_hand.xml
133-
${CMAKE_CURRENT_BINARY_DIR}/cube/right_hand.xml
139+
${CMAKE_CURRENT_BINARY_DIR}/rubik/right_hand.xml
134140
# copy hand assets from Menagerie
135141
COMMAND ${CMAKE_COMMAND} -E copy_directory
136142
${menagerie_SOURCE_DIR}/shadow_hand/assets
137-
${CMAKE_CURRENT_BINARY_DIR}/cube/assets
143+
${CMAKE_CURRENT_BINARY_DIR}/rubik/assets
138144

139145
# ALOHA
140146
COMMAND ${CMAKE_COMMAND} -E copy_directory
File renamed without changes.

mjpc/tasks/cube/solve.cc renamed to mjpc/tasks/rubik/solve.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "mjpc/tasks/cube/solve.h"
15+
#include "mjpc/tasks/rubik/solve.h"
1616

1717
#include <algorithm>
1818
#include <iostream>
@@ -27,12 +27,14 @@ namespace {
2727
constexpr static double kResetHeight = -0.1; // cube height to reset
2828
} // namespace
2929

30-
std::string CubeSolve::XmlPath() const { return GetModelPath("cube/task.xml"); }
31-
std::string CubeSolve::Name() const { return "Cube Solving"; }
30+
std::string Rubik::XmlPath() const {
31+
return GetModelPath("rubik/task.xml");
32+
}
33+
std::string Rubik::Name() const { return "Rubik"; }
3234

33-
CubeSolve::CubeSolve() : residual_(this) {
35+
Rubik::Rubik() : residual_(this) {
3436
// path to transition model xml
35-
std::string path = GetModelPath("cube/transition_model.xml");
37+
std::string path = GetModelPath("rubik/transition_model.xml");
3638

3739
// load transition model
3840
constexpr int kErrorLength = 1024;
@@ -46,15 +48,15 @@ CubeSolve::CubeSolve() : residual_(this) {
4648
std::fill(goal_cache_.begin(), goal_cache_.end(), 0.0);
4749
}
4850

49-
CubeSolve::~CubeSolve() {
51+
Rubik::~Rubik() {
5052
if (transition_data_) mj_deleteData(transition_data_);
5153
if (transition_model_) mj_deleteModel(transition_model_);
5254
}
5355

5456
// ---------- Residuals for cube solving manipulation task ----
5557
// Number of residuals:
5658
// ------------------------------------------------------------
57-
void CubeSolve::ResidualFn::Residual(const mjModel* model, const mjData* data,
59+
void Rubik::ResidualFn::Residual(const mjModel* model, const mjData* data,
5860
double* residual) const {
5961
// initialize counter
6062
int counter = 0;
@@ -135,7 +137,7 @@ void CubeSolve::ResidualFn::Residual(const mjModel* model, const mjData* data,
135137
// If cube is within tolerance or floor ->
136138
// reset cube into hand.
137139
// ---------------------------------------------------------
138-
void CubeSolve::TransitionLocked(mjModel* model, mjData* data) {
140+
void Rubik::TransitionLocked(mjModel* model, mjData* data) {
139141
if (transition_model_) {
140142
if (mode == kModeWait) {
141143
weight[11] = .01; // add penalty on joint movement

mjpc/tasks/cube/solve.h renamed to mjpc/tasks/rubik/solve.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef MJPC_TASKS_CUBE_SOLVE_H_
16-
#define MJPC_TASKS_CUBE_SOLVE_H_
15+
#ifndef MJPC_TASKS_RUBIK_SOLVE_H_
16+
#define MJPC_TASKS_RUBIK_SOLVE_H_
1717

1818
#include <algorithm>
1919
#include <memory>
@@ -25,14 +25,14 @@
2525

2626
namespace mjpc {
2727

28-
class CubeSolve : public Task {
28+
class Rubik : public Task {
2929
public:
3030
std::string Name() const override;
3131
std::string XmlPath() const override;
3232

3333
class ResidualFn : public BaseResidualFn {
3434
public:
35-
explicit ResidualFn(const CubeSolve* task, int current_mode = 0,
35+
explicit ResidualFn(const Rubik* task, int current_mode = 0,
3636
int goal_index = 0)
3737
: BaseResidualFn(task),
3838
current_mode_(current_mode),
@@ -41,18 +41,18 @@ class CubeSolve : public Task {
4141
double* residual) const override;
4242

4343
private:
44-
friend class CubeSolve;
44+
friend class Rubik;
4545
int current_mode_ = 0;
4646
int goal_index_ = 0;
4747
};
4848

49-
CubeSolve();
50-
~CubeSolve();
49+
Rubik();
50+
~Rubik();
5151

5252
void TransitionLocked(mjModel* model, mjData* data) override;
5353

5454
// modes
55-
enum CubeSolveMode {
55+
enum RubikMode {
5656
kModeScramble = 0,
5757
kModeSolve,
5858
kModeWait,
@@ -78,4 +78,4 @@ class CubeSolve : public Task {
7878

7979
} // namespace mjpc
8080

81-
#endif // MJPC_TASKS_CUBE_SOLVE_H_
81+
#endif // MJPC_TASKS_RUBIK_SOLVE_H_
File renamed without changes.

mjpc/tasks/tasks.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "mjpc/tasks/allegro/allegro.h"
2323
#include "mjpc/tasks/bimanual/bimanual.h"
2424
#include "mjpc/tasks/cartpole/cartpole.h"
25-
#include "mjpc/tasks/cube/solve.h"
2625
#include "mjpc/tasks/fingers/fingers.h"
2726
#include "mjpc/tasks/humanoid/stand/stand.h"
2827
#include "mjpc/tasks/humanoid/tracking/tracking.h"
@@ -34,6 +33,7 @@
3433
#include "mjpc/tasks/particle/particle.h"
3534
#include "mjpc/tasks/quadrotor/quadrotor.h"
3635
#include "mjpc/tasks/quadruped/quadruped.h"
36+
#include "mjpc/tasks/rubik/solve.h"
3737
#include "mjpc/tasks/shadow_reorient/hand.h"
3838
#include "mjpc/tasks/swimmer/swimmer.h"
3939
#include "mjpc/tasks/walker/walker.h"
@@ -45,7 +45,6 @@ std::vector<std::shared_ptr<Task>> GetTasks() {
4545
std::make_shared<Acrobot>(),
4646
std::make_shared<Allegro>(),
4747
std::make_shared<Bimanual>(),
48-
std::make_shared<CubeSolve>(),
4948
std::make_shared<Cartpole>(),
5049
std::make_shared<Fingers>(),
5150
std::make_shared<humanoid::Stand>(),
@@ -57,6 +56,7 @@ std::vector<std::shared_ptr<Task>> GetTasks() {
5756
std::make_shared<Panda>(),
5857
std::make_shared<Particle>(),
5958
std::make_shared<ParticleFixed>(),
59+
std::make_shared<Rubik>(),
6060
std::make_shared<ShadowReorient>(),
6161
std::make_shared<Quadrotor>(),
6262
std::make_shared<QuadrupedFlat>(),

0 commit comments

Comments
 (0)