MCPcopy Create free account
hub / github.com/TeleHuman/TextOp / main

Function main

TextOpDeploy/src/unitree_mujoco/simulate/src/main.cc:598–654  ·  view source on GitHub ↗

run event loop

Source from the content-addressed store, hash-verified

596
597// run event loop
598int main(int argc, char **argv)
599{
600 // display an error if running on macOS under Rosetta 2
601#if defined(__APPLE__) && defined(__AVX__)
602 if (rosetta_error_msg)
603 {
604 DisplayErrorDialogBox("Rosetta 2 is not supported", rosetta_error_msg);
605 std::exit(1);
606 }
607#endif
608
609 // print version, check compatibility
610 std::printf("MuJoCo version %s\n", mj_versionString());
611 if (mjVERSION_HEADER != mj_version())
612 {
613 mju_error("Headers and library have different versions");
614 }
615
616 // scan for libraries in the plugin directory to load additional plugins
617 scanPluginLibraries();
618
619 mjvCamera cam;
620 mjv_defaultCamera(&cam);
621
622 mjvOption opt;
623 mjv_defaultOption(&opt);
624
625 mjvPerturb pert;
626 mjv_defaultPerturb(&pert);
627
628 // Load simulation configuration
629 std::filesystem::path proj_dir = std::filesystem::path(getExecutableDir()).parent_path();
630 param::config.load_from_yaml(proj_dir / "config.yaml");
631 param::helper(argc, argv);
632 if (param::config.robot_scene.is_relative())
633 {
634 param::config.robot_scene = proj_dir.parent_path() / "unitree_robots" /
635 param::config.robot / param::config.robot_scene;
636 }
637
638 // simulate object encapsulates the UI
639 auto sim = std::make_unique<mj::Simulate>(std::make_unique<mj::GlfwAdapter>(), &cam, &opt,
640 &pert, /* is_passive = */ false);
641
642 sim->use_elastic_band_ = param::config.enable_elastic_band;
643
644 std::thread unitree_thread(UnitreeSdk2BridgeThread, nullptr);
645
646 // start physics thread
647 std::thread physicsthreadhandle(&PhysicsThread, sim.get(), param::config.robot_scene.c_str());
648 // start simulation UI loop (blocking call)
649 sim->RenderLoop();
650 physicsthreadhandle.join();
651
652 pthread_exit(NULL);
653 return 0;
654}

Callers

nothing calls this directly

Calls 5

scanPluginLibrariesFunction · 0.85
getExecutableDirFunction · 0.85
helperFunction · 0.85
load_from_yamlMethod · 0.80
RenderLoopMethod · 0.80

Tested by

no test coverage detected