Skip to content

Commit 73b9e19

Browse files
erez-tomcopybara-github
authored andcommitted
Specify start-up task by name alone.
PiperOrigin-RevId: 607639204 Change-Id: Id15323b62d01e344e9e271eb0e106e1b0fc55db6
1 parent 2b39d36 commit 73b9e19

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

mjpc/app.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
#include "mjpc/threadpool.h"
4141
#include "mjpc/utilities.h"
4242

43-
ABSL_FLAG(std::string, task, "", "Which model to load on startup.");
43+
ABSL_FLAG(std::string, task, "Quadruped Flat",
44+
"Which model to load on startup.");
4445
ABSL_FLAG(bool, planner_enabled, false,
4546
"If true, the planner will run on startup");
4647
ABSL_FLAG(float, sim_percent_realtime, 100,
@@ -392,7 +393,7 @@ void PhysicsLoop(mj::Simulate& sim) {
392393

393394
namespace mjpc {
394395

395-
MjpcApp::MjpcApp(std::vector<std::shared_ptr<mjpc::Task>> tasks, int task_id) {
396+
MjpcApp::MjpcApp(std::vector<std::shared_ptr<mjpc::Task>> tasks) {
396397
// MJPC
397398
printf("MuJoCo MPC (MJPC)\n");
398399

@@ -415,8 +416,8 @@ MjpcApp::MjpcApp(std::vector<std::shared_ptr<mjpc::Task>> tasks, int task_id) {
415416

416417
sim->agent->SetTaskList(std::move(tasks));
417418
std::string task_name = absl::GetFlag(FLAGS_task);
418-
if (task_name.empty()) {
419-
sim->agent->gui_task_id = task_id;
419+
if (task_name.empty()) { // shouldn't happen, flag has a default value
420+
sim->agent->gui_task_id = 0;
420421
} else {
421422
sim->agent->gui_task_id = sim->agent->GetTaskIdByName(task_name);
422423
if (sim->agent->gui_task_id == -1) {
@@ -519,8 +520,8 @@ mj::Simulate* MjpcApp::Sim() {
519520
return sim.get();
520521
}
521522

522-
void StartApp(std::vector<std::shared_ptr<mjpc::Task>> tasks, int task_id) {
523-
MjpcApp app(std::move(tasks), task_id);
523+
void StartApp(std::vector<std::shared_ptr<mjpc::Task>> tasks) {
524+
MjpcApp app(std::move(tasks));
524525
app.Start();
525526
}
526527

mjpc/app.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace mjpc {
2525
class MjpcApp {
2626
public:
27-
MjpcApp(std::vector<std::shared_ptr<mjpc::Task>> tasks, int task_id = 0);
27+
explicit MjpcApp(std::vector<std::shared_ptr<mjpc::Task>> tasks);
2828
MjpcApp(const MjpcApp&) = delete;
2929
MjpcApp& operator=(const MjpcApp&) = delete;
3030
~MjpcApp();
@@ -34,7 +34,7 @@ class MjpcApp {
3434
::mujoco::Simulate* Sim();
3535
};
3636

37-
void StartApp(std::vector<std::shared_ptr<mjpc::Task>> tasks, int task_id = 0);
37+
void StartApp(std::vector<std::shared_ptr<mjpc::Task>> tasks);
3838

3939
} // namespace mjpc
4040

mjpc/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ int main(int argc, char** argv) {
4747
#endif
4848
absl::ParseCommandLine(argc, argv);
4949

50-
mjpc::StartApp(mjpc::GetTasks(), 11); // start with quadruped flat
50+
mjpc::StartApp(mjpc::GetTasks());
5151
return 0;
5252
}

0 commit comments

Comments
 (0)