Skip to content

Commit 6d2c04c

Browse files
committed
update menagerie version for aloha
2 parents 792f943 + 1ecabed commit 6d2c04c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5129
-237
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ jobs:
1919
-DCMAKE_C_COMPILER:STRING=clang-12
2020
-DCMAKE_CXX_COMPILER:STRING=clang++-12
2121
-DMJPC_BUILD_GRPC_SERVICE:BOOL=ON
22-
additional_targets: "agent_server direct_server filter_server"
2322
tmpdir: "/tmp"
2423
- os: macos-12
2524
cmake_args: >-
2625
-G Ninja
2726
-DMJPC_BUILD_GRPC_SERVICE:BOOL=ON
28-
additional_targets: "agent_server direct_server filter_server"
2927
tmpdir: "/tmp"
3028

3129
name: "MuJoCo MPC on ${{ matrix.os }} ${{ matrix.additional_label }}"
@@ -43,9 +41,10 @@ jobs:
4341
libxrandr-dev
4442
libxi-dev
4543
ninja-build
44+
zlib1g-dev
4645
- name: Prepare macOS
4746
if: ${{ runner.os == 'macOS' }}
48-
run: brew install ninja
47+
run: brew install ninja zlib
4948
- name: Prepare Windows
5049
if: ${{ runner.os == 'Windows' }}
5150
# Install llvm 16 manually, remove after
@@ -68,10 +67,12 @@ jobs:
6867
$cmake_extra_args
6968
- name: Build MuJoCo MPC
7069
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 }}
70+
run: cmake --build . --config=Release ${{ matrix.cmake_build_args }}
7271
- name: Test MuJoCo MPC
7372
working-directory: build
74-
run: ctest -C Release --output-on-failure .
73+
run: >
74+
cd mjpc/test &&
75+
ctest -C Release --output-on-failure .
7576
- name: Notify team chat
7677
shell: bash
7778
env:

CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ set(MUJOCO_MPC_MUJOCO_GIT_TAG
6161
)
6262

6363
set(MUJOCO_MPC_MENAGERIE_GIT_TAG
64-
2b12d95d0f61abe91d4aad36cfdcd2ab31e8fce3
64+
aef3ee5c07ea51506e893a62fd832773ff0162c8
6565
CACHE STRING "Git revision for MuJoCo Menagerie."
6666
)
6767

@@ -87,19 +87,12 @@ findorfetch(
8787
EXCLUDE_FROM_ALL
8888
)
8989

90+
# TODO(nimrod): Update to the latest version of abseil, or use the one defined
91+
# by MuJoCo, once grpc fix their build issues.
9092
set(MUJOCO_DEP_VERSION_abseil
91-
c8a2f92586fe9b4e1aff049108f5db8064924d8e # LTS 20230125.1
93+
fb3621f4f897824c0dbe0615fa94543df6192f30 # LTS 20230802.1
9294
CACHE STRING "Version of `abseil` to be fetched."
93-
)
94-
95-
set(MUJOCO_DEP_VERSION_glfw3
96-
7482de6071d21db77a7236155da44c172a7f6c9e # 3.3.8
97-
CACHE STRING "Version of `glfw` to be fetched."
98-
)
99-
100-
set(MJPC_DEP_VERSION_lodepng
101-
b4ed2cd7ecf61d29076169b49199371456d4f90b
102-
CACHE STRING "Version of `lodepng` to be fetched."
95+
FORCE
10396
)
10497

10598
set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})
@@ -128,6 +121,9 @@ findorfetch(
128121

129122
set(ABSL_PROPAGATE_CXX_STD ON)
130123
set(ABSL_BUILD_TESTING OFF)
124+
# ABSL_ENABLE_INSTALL is needed for
125+
# https://github.com/protocolbuffers/protobuf/issues/12185#issuecomment-1594685860
126+
set(ABSL_ENABLE_INSTALL ON)
131127
findorfetch(
132128
USE_SYSTEM_PACKAGE
133129
OFF

cmake/MujocoLinkOptions.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function(get_mujoco_extra_link_options OUTPUT_VAR)
2323
set(EXTRA_LINK_OPTIONS)
2424

2525
if(WIN32)
26-
set(CMAKE_REQUIRED_LINK_OPTIONS "-fuse-ld=lld-link")
26+
set(CMAKE_REQUIRED_FLAGS "-fuse-ld=lld-link")
2727
check_c_source_compiles("int main() {}" SUPPORTS_LLD)
2828
if(SUPPORTS_LLD)
2929
set(EXTRA_LINK_OPTIONS
@@ -34,24 +34,24 @@ function(get_mujoco_extra_link_options OUTPUT_VAR)
3434
)
3535
endif()
3636
else()
37-
set(CMAKE_REQUIRED_LINK_OPTIONS "-fuse-ld=lld")
37+
set(CMAKE_REQUIRED_FLAGS "-fuse-ld=lld")
3838
check_c_source_compiles("int main() {}" SUPPORTS_LLD)
3939
if(SUPPORTS_LLD)
4040
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -fuse-ld=lld)
4141
else()
42-
set(CMAKE_REQUIRED_LINK_OPTIONS "-fuse-ld=gold")
42+
set(CMAKE_REQUIRED_FLAGS "-fuse-ld=gold")
4343
check_c_source_compiles("int main() {}" SUPPORTS_GOLD)
4444
if(SUPPORTS_GOLD)
4545
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -fuse-ld=gold)
4646
endif()
4747
endif()
4848

49-
set(CMAKE_REQUIRED_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} "-Wl,--gc-sections")
49+
set(CMAKE_REQUIRED_FLAGS ${EXTRA_LINK_OPTIONS} "-Wl,--gc-sections")
5050
check_c_source_compiles("int main() {}" SUPPORTS_GC_SECTIONS)
5151
if(SUPPORTS_GC_SECTIONS)
5252
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -Wl,--gc-sections)
5353
else()
54-
set(CMAKE_REQUIRED_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} "-Wl,-dead_strip")
54+
set(CMAKE_REQUIRED_FLAGS ${EXTRA_LINK_OPTIONS} "-Wl,-dead_strip")
5555
check_c_source_compiles("int main() {}" SUPPORTS_DEAD_STRIP)
5656
if(SUPPORTS_DEAD_STRIP)
5757
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -Wl,-dead_strip)

mjpc/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ add_library(
3838
tasks/tasks.h
3939
tasks/acrobot/acrobot.cc
4040
tasks/acrobot/acrobot.h
41+
tasks/bimanual/bimanual.cc
42+
tasks/bimanual/bimanual.h
4143
tasks/cartpole/cartpole.cc
4244
tasks/cartpole/cartpole.h
45+
tasks/cube/solve.cc
46+
tasks/cube/solve.h
4347
tasks/fingers/fingers.cc
4448
tasks/fingers/fingers.h
4549
tasks/hand/hand.cc
@@ -81,6 +85,8 @@ add_library(
8185
planners/cross_entropy/planner.h
8286
planners/robust/robust_planner.cc
8387
planners/robust/robust_planner.h
88+
planners/sample_gradient/planner.cc
89+
planners/sample_gradient/planner.h
8490
planners/sampling/planner.cc
8591
planners/sampling/planner.h
8692
planners/sampling/policy.cc
@@ -118,6 +124,8 @@ add_library(
118124
direct/trajectory.h
119125
direct/model_parameters.cc
120126
direct/model_parameters.h
127+
spline/spline.cc
128+
spline/spline.h
121129
app.cc
122130
app.h
123131
norm.cc
@@ -134,8 +142,11 @@ target_compile_definitions(libmjpc PRIVATE MJSIMULATE_STATIC)
134142
target_link_libraries(
135143
libmjpc
136144
absl::any_invocable
145+
absl::check
137146
absl::flat_hash_map
147+
absl::log
138148
absl::random_random
149+
absl::span
139150
glfw
140151
lodepng
141152
mujoco::mujoco
@@ -173,6 +184,28 @@ if(APPLE)
173184
target_link_libraries(mjpc "-framework Cocoa")
174185
endif()
175186

187+
add_executable(
188+
testspeed
189+
testspeed_app.cc
190+
testspeed.h
191+
testspeed.cc
192+
)
193+
target_link_libraries(
194+
testspeed
195+
absl::flags
196+
absl::flags_parse
197+
absl::random_random
198+
absl::strings
199+
libmjpc
200+
mujoco::mujoco
201+
threadpool
202+
Threads::Threads
203+
)
204+
target_include_directories(testspeed PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
205+
target_compile_options(testspeed PUBLIC ${MJPC_COMPILE_OPTIONS})
206+
target_link_options(testspeed PRIVATE ${MJPC_LINK_OPTIONS})
207+
target_compile_definitions(testspeed PRIVATE MJSIMULATE_STATIC)
208+
176209
add_subdirectory(tasks)
177210

178211
if(BUILD_TESTING AND MJPC_BUILD_TESTS)

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/agent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class Agent {
136136
mjpc::Planner& ActivePlanner() const { return *planners_[planner_]; }
137137
mjpc::Estimator& ActiveEstimator() const { return *estimators_[estimator_]; }
138138
int ActiveEstimatorIndex() const { return estimator_; }
139+
double ComputeTime() const { return agent_compute_time_; }
139140
Task* ActiveTask() const { return tasks_[active_task_id_].get(); }
140141
// a residual function that can be used from trajectory rollouts. must only
141142
// be used from trajectory rollout threads (no locking).

mjpc/direct/direct.h

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

15-
#ifndef MJPC_DIRECT_OPTIMIZER_H_
16-
#define MJPC_DIRECT_OPTIMIZER_H_
15+
#ifndef MJPC_DIRECT_DIRECT_H_
16+
#define MJPC_DIRECT_DIRECT_H_
1717

1818
#include <memory>
19-
#include <mutex>
2019
#include <string>
2120
#include <vector>
2221

@@ -65,7 +64,7 @@ class Direct {
6564
: model_parameters_(LoadModelParameters()), pool_(num_threads) {}
6665

6766
// constructor
68-
Direct(const mjModel* model, int length = 3, int max_history = 0);
67+
explicit Direct(const mjModel* model, int length = 3, int max_history = 0);
6968

7069
// destructor
7170
virtual ~Direct() {
@@ -510,4 +509,4 @@ std::string StatusString(int code);
510509

511510
} // namespace mjpc
512511

513-
#endif // MJPC_DIRECT_OPTIMIZER_H_
512+
#endif // MJPC_DIRECT_DIRECT_H_

mjpc/estimators/batch.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "mjpc/array_safety.h"
2525
#include "mjpc/estimators/estimator.h"
2626
#include "mjpc/direct/direct.h"
27-
#include "mjpc/norm.h"
2827
#include "mjpc/threadpool.h"
2928
#include "mjpc/utilities.h"
3029

mjpc/grpc/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ set(BUILD_SHARED_LIBS
2020
CACHE INTERNAL "Build SHARED libraries"
2121
)
2222

23+
find_package(ZLIB REQUIRED)
24+
set(gRPC_ZLIB_PROVIDER "package" CACHE INTERNAL "")
25+
set(ZLIB_BUILD_EXAMPLES OFF)
26+
2327
findorfetch(
2428
USE_SYSTEM_PACKAGE
2529
OFF
@@ -30,14 +34,11 @@ findorfetch(
3034
GIT_REPO
3135
https://github.com/grpc/grpc
3236
GIT_TAG
33-
v1.53.0
37+
v1.60.1
3438
TARGETS
3539
gRPC
3640
)
3741

38-
find_package(ZLIB REQUIRED)
39-
set(gRPC_ZLIB_PROVIDER "package" CACHE INTERNAL "")
40-
set(ZLIB_BUILD_EXAMPLES OFF)
4142
set(_PROTOBUF_LIBPROTOBUF libprotobuf)
4243
set(_REFLECTION grpc++_reflection)
4344
set(_PROTOBUF_PROTOC $<TARGET_FILE:protoc>)

mjpc/grpc/agent.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ service Agent {
3939
returns (GetTaskParametersResponse);
4040
// Set cost weights.
4141
rpc SetCostWeights(SetCostWeightsRequest) returns (SetCostWeightsResponse);
42+
// Get cost term residuals.
43+
rpc GetResiduals(GetResidualsRequest) returns (GetResidualsResponse);
4244
// Get cost term values.
4345
rpc GetCostValuesAndWeights(GetCostValuesAndWeightsRequest)
4446
returns (GetCostValuesAndWeightsResponse);
@@ -113,6 +115,16 @@ message GetActionResponse {
113115
repeated float action = 1 [packed = true];
114116
}
115117

118+
message GetResidualsRequest {}
119+
120+
message Residual {
121+
repeated double values = 1;
122+
}
123+
124+
message GetResidualsResponse {
125+
map<string, Residual> values = 1;
126+
}
127+
116128
message GetCostValuesAndWeightsRequest {}
117129

118130
message ValueAndWeight {

0 commit comments

Comments
 (0)