[DR02][Locomotion][Deployment]Deploying AMP&Mimic Policies on DR02 Pro:From Simulation to Real Robot
DEEP Robotics · Uploaded · 27:57 · Watch on YouTube
Deep Robotics engineer Yu Inuo walks viewers through the deep-robotics-sdk2 project structure and its build steps. He shows how to run AMP and Mimic motion policies in simulation and on the DR02 Pro, switching modes by keyboard or gamepad.
Transcript
Captions as a .vtt fileEmbed with the transcript
- 0:07As you can see, the robot is performing the fixed routine motion.
- 0:12Hello everyone, I'm Yu Inuo from Deep Robotics.
- 0:21In our previous two videos, we introduced two popular algorithms for humanoid robot motion control, AMP and MIMIC.
- 0:30We also briefly explained how to deploy the policies we trained.
- 0:34In this video, we will walk you through the complete process of deploying trained motion control policies
- 0:41on the DR02 Pro robot using keyboard or gamepad.
- 0:46We will start with a brief introduction to the STK2 project structure.
- 0:51Then we will demonstrate how to build and deploy the policies,
- 0:55how to replace trained policies and cover some important safety precautions for real robot deployment.
- 1:06First, let's take a look at the STK2 project structure.
- 1:11The source-common directory contains common data types and general-purpose helper functions.
- 1:20And the scripts directory provides supporting scripts.
- 1:25The third-party directory contains third-party dependencies.
- 1:32The DR02 Pro directory is the main focus of this video.
- 1:37Its state machine module implements the robot's state machine,
- 1:42managing the control flow through transitions between different states.
- 1:47This directory also contains functionality for motion control,
- 1:52battery status monitoring, user-controller interaction, and other features.
- 1:57The DR02STD directory has a similar structure,
- 2:03but it is mainly intended for the DR02 standards robot.
- 2:08Alright, let's go over the simulation deployment process.
- 2:13First, we need to clone three repositories.
- 2:18The first one is STK2.
- 2:22And the second is the simulation.
- 2:25That's the Mojoku simulation site.
- 2:27And the third is the messages.
- 2:30The repository that stores ROS2 message type definitions.
- 2:35We will clone all three into the same directory named DR02deploy.
- 2:42Then we build them following the readme in each repository.
- 2:49The first step is to build the simulation and the messages repls.
- 2:54The readme in the simulation repo provides the build instructions.
- 3:07And the very first step is to build the messages repo.
- 3:12The simulation repo comes with a ready-to-use build script.
- 3:17Just copy the corresponding command and run it in your terminal.
- 3:22And here, remember to adjust the path to your actual local path,
- 3:44which is the parent directory.
- 3:47Then wait a moment for it to complete.
- 3:50Okay, now the messages library is built and installed.
- 4:05Next, we set up the simulation repo.
- 4:08First, we need to install the virtual environment.
- 4:14We use a virtual environment to manage the Python environment from Draco.
- 4:19So you need to install dependencies first.
- 4:24And run the relevant commands from inside the simulation directory.
- 4:29And be sure to deactivate your current conda environment before running them.
- 4:37Because my machine has cached the packages,
- 4:45so the installation goes pretty fast here.
- 4:48Once it's done, you can find the virtual environment inside the simulation repository.
- 4:56And after that, we can run the simulation script.
- 5:00First, source the ROS environment.
- 5:03I'm using Ubuntu 24.04 with ROSJASY.
- 5:09So I will source the setup file for that version.
- 5:12And then run the simulation Python file.
- 5:21And here for the product parameter, you can use either DRDO2 Pro or STD.
- 5:38And with that, the simulation program is up and running.
- 5:47Now let's set the simulation aside for now.
- 5:54And move on to the second step, building the SDK.
- 5:58Let's first look at the guidance readme document in the SDK.
- 6:06And we can find the instructions for simulation operations in the Quick Start section.
- 6:16And here it also mentions that the messages and the simulation repositories need to be installed first.
- 6:29Which aligns with the steps we just went through.
- 6:33And now let's build the SDK.
- 6:37First, CD into the SDK2 directory.
- 6:41And run the build command.
- 6:43Here I set the build theme option to on here.
- 6:48And you can ignore any warnings that come up during the build for now.
- 6:55Okay, once the build finishes, we can run the SDK.
- 7:05Just one thing to keep in mind.
- 7:12The terminal running the SDK and the terminal running the major code simulation must be in the same ROS domain.
- 7:20Because we didn't set a custom domain when we launched the simulation.
- 7:24So we don't need to add any extra configuration here.
- 7:29After that, running the SDK takes three steps.
- 7:34First, source the ROS environment.
- 7:37And the second, source the SDK's install directory.
- 7:48And finally, run the ROS2RUN command.
- 7:56Okay, once it starts successfully, the simulation will connect automatically.
- 8:10And we can control the robot with the keyboard.
- 8:13First, press the Z key to put the robot into zero-pole state.
- 8:21From there, you can press C to switch to the AMP policy.
- 8:25Or V to switch to the MIMIC policy.
- 8:28Now, let's press C to switch to AMP.
- 8:33Here we go.
- 8:35Now the switch is complete.
- 8:37And we can control the movement with WASD and QE on the keyboard.
- 8:44W moves forward.
- 8:48And S moves backward.
- 8:56Right now, we are in the AMP mode under our control.
- 9:04While in this state, just press V to switch to a MIMIC motion.
- 9:09This MIMIC motion is a fixed routine.
- 9:15And when the motion finishes, it will automatically switch back to the AMP policy.
- 9:24And you can also press C to manually switch back to AMP during the MIMIC motion.
- 9:30But there is a condition check.
- 9:38If the robot's body posture does not meet the requirements or the joint velocities are too high, the switch won't go through.
- 9:49Now we are back to the AMP working policy.
- 9:53And that covers the basic simulation deployment workflow.
- 10:03Now we can press R to enter damping mode.
- 10:09And then close the terminal.
- 10:11Next, let's go over how to replace the current train policy.
- 10:18First, we can find the active policy files in the SDK2 repo.
- 10:26They are located under the state machine directory for DR02 Pro.
- 10:37And with two folders, policy and motion data.
- 10:44The policy folder contains the ONIX files used by AMP and MIMIC.
- 10:49And here you can see AMP policy and the pickup box and the physical routine for MIMIC.
- 10:55And the motion data folder holds the MPZ data files required for MIMIC.
- 11:12And the exact file passes are defined in the individual runner files inside the policy runner folder,
- 11:19which is specified on the next file passes.
- 11:24And the MIMIC runner also defines the corresponding ONIX file name and the MPZ file name.
- 11:30So replacing a policy is straightforward.
- 11:38Swap out the old ONIX policy file with the new one.
- 11:44Then update the file name in the runner file accordingly.
- 11:48And for example, if we want to change the motion from physical routine to a pickup box,
- 11:57we just edit the file name here.
- 12:00Here we copied a new MPZ file into the motion data directory to replace the old one.
- 12:24And now the motion becomes the pickup box action.
- 12:37After updating the file names, we need to rebuild the SDK.
- 12:42Okay, once rebuilt, source the environment again and restart the SDK.
- 12:57You will also need to restart the simulation side.
- 13:03Again, press Z to go back to the zero-pulse and then press V.
- 13:12Now it's running the box pickup motion.
- 13:17Once the motion finishes, it automatically switches back to the AMP policy.
- 13:25The policy switching logic in simulation is exactly the same as on the real robot since we are using the same SDK.
- 13:35So when we cover the real robot later, we won't repeat the code logic.
- 13:47We'll just focus on the physical operation steps.
- 13:53Alright, let's close all the programs.
- 13:55And that's basically everything for simulation part.
- 13:59One final important note.
- 14:01The configuration parameters used during training must match the ones in the SDK.
- 14:07That includes the observation scale, the joint Kp and Kd values, and also the default joint positions.
- 14:18And all of them need to align exactly.
- 14:25So that's the complete workflow.
- 14:29Just make sure you know where the policy files are stored and where the policy runner is located.
- 14:37You can look into the detailed code logic on your own later.
- 14:42Next, let's focus on the deployment process on the real robot.
- 14:47First, we need to prepare the DR-02 Pro robot and its battery, the gamepad controller, and your own computer for deploying the code.
- 14:59Before powering on the robot, you need to locate the hardware emergency system.
- 15:06First, press the emergency stop button and press it to trigger an emergency stop when there is any danger.
- 15:18Once the risk is cleared, twist it clockwise to release.
- 15:25Then, tap and long press the switch button to turn on the robot power.
- 15:35And finally, press the button to turn on the robot host.
- 15:44Unlike simulation deployment, real robot deployment mainly requires two repositories, SDK 2 and messages.
- 16:00So first, open the guide documentation in SDK 2 and find the real robot deployment section under Quick Start.
- 16:10This section describes the complete real robot deployment procedure.
- 16:18Here, there are currently three main deployment options.
- 16:24Deploying directly on your own development computer, or connecting to the robot's motion control host, referred to as 103, or connecting to the perception host, referred to as 106.
- 16:42Today, we will use the 103 motion control host as our example.
- 16:51First, connect to the robot's Wi-Fi network, and we run a pin test to make sure your computer can communicate with the robot properly.
- 17:08Then, use the scp command to transfer the SDK 2 and message's repositories to the 103 motion control host.
- 17:20Before running the command, remember to update the file path, username, and host address to match your actual setup.
- 17:33Since the files are transferred over Wi-Fi, the network conditions will affect the transfer speed.
- 17:43Generally, the closer your computer is to the robot, the faster the transfer will be.
- 17:55After the transfer is complete, use SSH to connect to the 103 motion control host, and verify that both repositories have been copied successfully.
- 18:14Next, cd into the SDK 2 folder, and run the build commands as instructed in the document.
- 18:23The guide tells us to build the messages library on the robot's motion control host first.
- 18:32The motion control host runs Ubuntu 24.04, paired with ROS2 Jazzy.
- 18:40The build process will take some time.
- 18:44While we are waiting, let's go over a few more deployment details.
- 18:49Before deployment, we need to switch the robot into developer mode.
- 19:04The developer mode mainly provides three options.
- 19:10High level motion control mode, whole body joint control mode, and upper body joint control mode.
- 19:17Since we are deploying AMP and Mimic policies, we need to enter whole body joint control mode, and use the state machine to manage policy execution and transitions between states.
- 19:31You can enter developer mode, either with the gamepad, or by sending commands through the same sample programs provided in SDK 2.
- 19:43But in this video, we will use the gamepad for switching.
- 19:48First, turn on the gamepad, and make sure the robot is powered on and is in idle state.
- 19:55And then, we open the motion control app.
- 20:00Check the top right corner to confirm the gamepad is connected to the robot via Wi-Fi.
- 20:07Then select developer mode in the top left of the interface, and tab full body development to enter whole body joint control mode.
- 20:24To exit developer mode, simply tap exit development on the gamepad, and then switch back to the normal mode.
- 20:35Next, let's briefly review the gamepad mapping used by the real robot state machine.
- 20:45L1 switches the robot from idle state to zero position.
- 20:51L2 switches the robot to AMP from either zero position or mimic state.
- 20:57L1 switches from AMP to mimic state, and L2 triggers the whole body soft emergency stop.
- 21:09Finally, the red button in the upper right corner can also trigger the whole body soft emergency stop and exit developer mode.
- 21:20Please note that the exact button functions should always be verified against the actual implementation in the project.
- 21:30Now, the messages library has finished building, so we can continue with SDK 2.
- 21:37Before building, delete the old build logs and install directories in SDK 2 to prevent the previous building results from interfering with the current build.
- 21:50Then, run the two commands shown here.
- 21:56Here, select dr02pro as the package and set the build platform to ARM.
- 22:10Now, wait for the build to finish.
- 22:14Once the build is complete, follow the instructions in the state machine guide to source the ROS2 and SDK 2 environments.
- 22:26Then, launch the state machine program.
- 22:35When the terminal displays the corresponding start-up messages, it indicates that the program has started successfully.
- 22:48First, press L1 to move the robot into the low position.
- 22:53Okay, and before proceeding, make sure the robot's posture is stable and both feet are properly on the ground.
- 23:06Then, you can switch to AMP or mimic policy as needed.
- 23:14When deploying on a real robot, there are several safety precautions that require special attention.
- 23:21First, before running the control program, make sure the robot has entered the correct develop mode.
- 23:29Second, make sure there is enough space around the robot.
- 23:33Keep people and obstacles outside its range of motion.
- 23:37Third, before switching from zero position to policy control, confirm that the robot is standing steadily and both feet are firmly on the ground.
- 23:51Fourth, there must be only one active control command publisher at a time.
- 24:10This prevents multiple programs from controlling the robot simultaneously.
- 24:15Fifth, if the robot moves abnormally or there is any other safety risk, use the gamepad emergency stop immediately.
- 24:28Or use the hardware emergency stop button if necessary.
- 24:34Once we've confirmed that the deployment environment is safe, just press L2 to enter the AMP policy.
- 24:42Then, you can use the gamepad joystick to control the movement.
- 24:50The left joystick controls forward, backward, left, and right motion.
- 24:56And the right joystick controls turning.
- 25:00Now, let's press R1 to enter the mimic policy.
- 25:32As you can see, the robot is performing the fifth routine motion.
- 25:42And once the mimic motion finishes, the robot automatically switches back to the AMP policy.
- 25:49After we are done running the policy, first press R2 to put the robot into the soft emergency stop state.
- 26:01And confirm that the robot has stopped moving.
- 26:08And then, press Ctrl-C to terminate the motion control program.
- 26:15Next, exit the developer mode and switch back to the normal mode.
- 26:23Finally, power off the robot host.
- 26:30And then, tap and non-press the switch button to turn off the battery power.
- 26:40And that all wraps up our full real robot deployment process.
- 26:47That covers the deployment process for DR-02 Pro motion control policies from simulation to the real robot.
- 26:55And we've covered how to build and run the simulation environment, switch between and replace AMP and mimic policies,
- 27:04and deploy the policies on the real robot while following the necessary safety procedures.
- 27:12The related projects are open source now.
- 27:15You can find the SDK 2 simulation message repositories and more detailed installation and troubleshooting instructions
- 27:24through the link in the video description.
- 27:29Feel free to clone our repositories on GitHub and try deploying and testing your own trained motion control policies.
- 27:37Thank you for watching, and see you in the next video.
Discussion
A mail when somebody comments. No account needed.
The newsletter
Get our free newsletter with new robots, prices and robotics news.