> For the complete documentation index, see [llms.txt](https://idminer.gitbook.io/robotis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://idminer.gitbook.io/robotis/part-3.-robotis-op3-ren-xing-ji-qi-ren/4.-robotis-ros-tao-jian/4.1.-robotis-op3/4.1.2.-op3-manager/4.1.2.5.-yuan-shi-ma.md).

# 4.1.2.5. 原始碼

**op3\_manager** 的結構

* 使用 Robot 檔案（.robot）和 關節初始化檔案（.yaml）來初始化。
* 應用 offset 偏移檔（.yaml）。&#x20;
* 添加模組（每個模組管理控制或感測器相關功能的計算）。
* 在控制器中啟動計時器。&#x20;
* 根據 .robot 檔案中所寫的頻率，與 Dynamixels 智能馬達和 OpenCR 控制器交換數據。

```
...

// initialize robot
if (controller->initialize(g_robot_file, g_init_file) == false)
{
  ROS_ERROR("ROBOTIS Controller Initialize Fail!");
  return -1;
}

// load offset
if (g_offset_file != "")
  controller->loadOffset(g_offset_file);

sleep(1);

/* Add Sensor Module */
controller->addSensorModule((SensorModule*) OpenCRModule::getInstance());

/* Add Motion Module */
controller->addMotionModule((MotionModule*) ActionModule::getInstance());
controller->addMotionModule((MotionModule*) BaseModule::getInstance());
controller->addMotionModule((MotionModule*) HeadControlModule::getInstance());
controller->addMotionModule((MotionModule*) WalkingModule::getInstance());

// start timer
controller->startTimer();

...
```
