WEBVTT

NOTE
[DR02][Locomotion][Deployment]Deploying AMP&Mimic Policies on DR02 Pro:From Simulation to Real Robot
Transcript by RoboGeeks: https://robogeeks.org/videos/6G4IpndLDF0

1
00:00:07.860 --> 00:00:12.360
As you can see, the robot is performing the fixed routine motion.

2
00:00:12.360 --> 00:00:21.710
Hello everyone, I'm Yu Inuo from Deep Robotics.

3
00:00:21.710 --> 00:00:30.210
In our previous two videos, we introduced two popular algorithms for humanoid robot motion control, AMP and MIMIC.

4
00:00:30.210 --> 00:00:34.210
We also briefly explained how to deploy the policies we trained.

5
00:00:34.210 --> 00:00:41.210
In this video, we will walk you through the complete process of deploying trained motion control policies

6
00:00:41.210 --> 00:00:46.210
on the DR02 Pro robot using keyboard or gamepad.

7
00:00:46.210 --> 00:00:51.210
We will start with a brief introduction to the STK2 project structure.

8
00:00:51.210 --> 00:00:55.210
Then we will demonstrate how to build and deploy the policies,

9
00:00:55.210 --> 00:01:06.120
how to replace trained policies and cover some important safety precautions for real robot deployment.

10
00:01:06.120 --> 00:01:11.120
First, let's take a look at the STK2 project structure.

11
00:01:11.120 --> 00:01:20.640
The source-common directory contains common data types and general-purpose helper functions.

12
00:01:20.640 --> 00:01:25.640
And the scripts directory provides supporting scripts.

13
00:01:25.640 --> 00:01:32.330
The third-party directory contains third-party dependencies.

14
00:01:32.330 --> 00:01:37.330
The DR02 Pro directory is the main focus of this video.

15
00:01:37.330 --> 00:01:42.330
Its state machine module implements the robot's state machine,

16
00:01:42.330 --> 00:01:47.330
managing the control flow through transitions between different states.

17
00:01:47.330 --> 00:01:52.330
This directory also contains functionality for motion control,

18
00:01:52.330 --> 00:01:57.330
battery status monitoring, user-controller interaction, and other features.

19
00:01:57.330 --> 00:02:03.510
The DR02STD directory has a similar structure,

20
00:02:03.510 --> 00:02:08.510
but it is mainly intended for the DR02 standards robot.

21
00:02:08.510 --> 00:02:13.510
Alright, let's go over the simulation deployment process.

22
00:02:13.510 --> 00:02:18.510
First, we need to clone three repositories.

23
00:02:18.510 --> 00:02:22.510
The first one is STK2.

24
00:02:22.510 --> 00:02:25.510
And the second is the simulation.

25
00:02:25.510 --> 00:02:27.510
That's the Mojoku simulation site.

26
00:02:27.510 --> 00:02:30.510
And the third is the messages.

27
00:02:30.510 --> 00:02:35.510
The repository that stores ROS2 message type definitions.

28
00:02:35.510 --> 00:02:42.510
We will clone all three into the same directory named DR02deploy.

29
00:02:42.510 --> 00:02:49.140
Then we build them following the readme in each repository.

30
00:02:49.140 --> 00:02:54.140
The first step is to build the simulation and the messages repls.

31
00:02:54.140 --> 00:03:07.380
The readme in the simulation repo provides the build instructions.

32
00:03:07.380 --> 00:03:12.380
And the very first step is to build the messages repo.

33
00:03:12.380 --> 00:03:17.380
The simulation repo comes with a ready-to-use build script.

34
00:03:17.380 --> 00:03:22.380
Just copy the corresponding command and run it in your terminal.

35
00:03:22.380 --> 00:03:44.150
And here, remember to adjust the path to your actual local path,

36
00:03:44.150 --> 00:03:47.150
which is the parent directory.

37
00:03:47.150 --> 00:03:50.150
Then wait a moment for it to complete.

38
00:03:50.150 --> 00:04:05.570
Okay, now the messages library is built and installed.

39
00:04:05.570 --> 00:04:08.570
Next, we set up the simulation repo.

40
00:04:08.570 --> 00:04:14.980
First, we need to install the virtual environment.

41
00:04:14.980 --> 00:04:19.980
We use a virtual environment to manage the Python environment from Draco.

42
00:04:19.980 --> 00:04:24.980
So you need to install dependencies first.

43
00:04:24.980 --> 00:04:29.980
And run the relevant commands from inside the simulation directory.

44
00:04:29.980 --> 00:04:37.890
And be sure to deactivate your current conda environment before running them.

45
00:04:37.890 --> 00:04:45.000
Because my machine has cached the packages,

46
00:04:45.000 --> 00:04:48.000
so the installation goes pretty fast here.

47
00:04:48.000 --> 00:04:56.000
Once it's done, you can find the virtual environment inside the simulation repository.

48
00:04:56.000 --> 00:05:00.000
And after that, we can run the simulation script.

49
00:05:00.000 --> 00:05:03.000
First, source the ROS environment.

50
00:05:03.000 --> 00:05:09.000
I'm using Ubuntu 24.04 with ROSJASY.

51
00:05:09.000 --> 00:05:12.000
So I will source the setup file for that version.

52
00:05:12.000 --> 00:05:21.910
And then run the simulation Python file.

53
00:05:21.910 --> 00:05:38.280
And here for the product parameter, you can use either DRDO2 Pro or STD.

54
00:05:38.280 --> 00:05:47.810
And with that, the simulation program is up and running.

55
00:05:47.810 --> 00:05:54.500
Now let's set the simulation aside for now.

56
00:05:54.500 --> 00:05:58.500
And move on to the second step, building the SDK.

57
00:05:58.500 --> 00:06:06.220
Let's first look at the guidance readme document in the SDK.

58
00:06:06.220 --> 00:06:16.680
And we can find the instructions for simulation operations in the Quick Start section.

59
00:06:16.680 --> 00:06:29.000
And here it also mentions that the messages and the simulation repositories need to be installed first.

60
00:06:29.000 --> 00:06:33.000
Which aligns with the steps we just went through.

61
00:06:33.000 --> 00:06:37.120
And now let's build the SDK.

62
00:06:37.120 --> 00:06:41.120
First, CD into the SDK2 directory.

63
00:06:41.120 --> 00:06:43.120
And run the build command.

64
00:06:43.120 --> 00:06:48.810
Here I set the build theme option to on here.

65
00:06:48.810 --> 00:06:55.800
And you can ignore any warnings that come up during the build for now.

66
00:06:55.800 --> 00:07:05.780
Okay, once the build finishes, we can run the SDK.

67
00:07:05.780 --> 00:07:12.170
Just one thing to keep in mind.

68
00:07:12.170 --> 00:07:20.170
The terminal running the SDK and the terminal running the major code simulation must be in the same ROS domain.

69
00:07:20.170 --> 00:07:24.170
Because we didn't set a custom domain when we launched the simulation.

70
00:07:24.170 --> 00:07:29.170
So we don't need to add any extra configuration here.

71
00:07:29.170 --> 00:07:34.170
After that, running the SDK takes three steps.

72
00:07:34.170 --> 00:07:37.170
First, source the ROS environment.

73
00:07:37.170 --> 00:07:48.850
And the second, source the SDK's install directory.

74
00:07:48.850 --> 00:07:56.570
And finally, run the ROS2RUN command.

75
00:07:56.570 --> 00:08:10.920
Okay, once it starts successfully, the simulation will connect automatically.

76
00:08:10.920 --> 00:08:13.920
And we can control the robot with the keyboard.

77
00:08:13.920 --> 00:08:21.480
First, press the Z key to put the robot into zero-pole state.

78
00:08:21.480 --> 00:08:25.480
From there, you can press C to switch to the AMP policy.

79
00:08:25.480 --> 00:08:28.480
Or V to switch to the MIMIC policy.

80
00:08:28.480 --> 00:08:33.880
Now, let's press C to switch to AMP.

81
00:08:33.880 --> 00:08:35.880
Here we go.

82
00:08:35.880 --> 00:08:37.880
Now the switch is complete.

83
00:08:37.880 --> 00:08:44.220
And we can control the movement with WASD and QE on the keyboard.

84
00:08:44.220 --> 00:08:48.010
W moves forward.

85
00:08:48.010 --> 00:08:56.360
And S moves backward.

86
00:08:56.360 --> 00:09:04.520
Right now, we are in the AMP mode under our control.

87
00:09:04.520 --> 00:09:09.520
While in this state, just press V to switch to a MIMIC motion.

88
00:09:09.520 --> 00:09:15.110
This MIMIC motion is a fixed routine.

89
00:09:15.110 --> 00:09:24.660
And when the motion finishes, it will automatically switch back to the AMP policy.

90
00:09:24.660 --> 00:09:30.940
And you can also press C to manually switch back to AMP during the MIMIC motion.

91
00:09:30.940 --> 00:09:38.010
But there is a condition check.

92
00:09:38.010 --> 00:09:49.010
If the robot's body posture does not meet the requirements or the joint velocities are too high, the switch won't go through.

93
00:09:49.010 --> 00:09:53.290
Now we are back to the AMP working policy.

94
00:09:53.290 --> 00:10:03.530
And that covers the basic simulation deployment workflow.

95
00:10:03.530 --> 00:10:09.780
Now we can press R to enter damping mode.

96
00:10:09.780 --> 00:10:11.780
And then close the terminal.

97
00:10:11.780 --> 00:10:18.210
Next, let's go over how to replace the current train policy.

98
00:10:18.210 --> 00:10:26.260
First, we can find the active policy files in the SDK2 repo.

99
00:10:26.260 --> 00:10:37.340
They are located under the state machine directory for DR02 Pro.

100
00:10:37.340 --> 00:10:44.940
And with two folders, policy and motion data.

101
00:10:44.940 --> 00:10:49.940
The policy folder contains the ONIX files used by AMP and MIMIC.

102
00:10:49.940 --> 00:10:55.940
And here you can see AMP policy and the pickup box and the physical routine for MIMIC.

103
00:10:55.940 --> 00:11:12.960
And the motion data folder holds the MPZ data files required for MIMIC.

104
00:11:12.960 --> 00:11:19.960
And the exact file passes are defined in the individual runner files inside the policy runner folder,

105
00:11:19.960 --> 00:11:24.960
which is specified on the next file passes.

106
00:11:24.960 --> 00:11:30.960
And the MIMIC runner also defines the corresponding ONIX file name and the MPZ file name.

107
00:11:30.960 --> 00:11:38.320
So replacing a policy is straightforward.

108
00:11:38.320 --> 00:11:44.320
Swap out the old ONIX policy file with the new one.

109
00:11:44.320 --> 00:11:48.320
Then update the file name in the runner file accordingly.

110
00:11:48.320 --> 00:11:57.010
And for example, if we want to change the motion from physical routine to a pickup box,

111
00:11:57.010 --> 00:12:00.010
we just edit the file name here.

112
00:12:00.010 --> 00:12:24.240
Here we copied a new MPZ file into the motion data directory to replace the old one.

113
00:12:24.240 --> 00:12:37.240
And now the motion becomes the pickup box action.

114
00:12:37.240 --> 00:12:42.240
After updating the file names, we need to rebuild the SDK.

115
00:12:42.240 --> 00:12:57.910
Okay, once rebuilt, source the environment again and restart the SDK.

116
00:12:57.910 --> 00:13:03.800
You will also need to restart the simulation side.

117
00:13:03.800 --> 00:13:12.070
Again, press Z to go back to the zero-pulse and then press V.

118
00:13:12.070 --> 00:13:17.560
Now it's running the box pickup motion.

119
00:13:17.560 --> 00:13:25.670
Once the motion finishes, it automatically switches back to the AMP policy.

120
00:13:25.670 --> 00:13:35.670
The policy switching logic in simulation is exactly the same as on the real robot since we are using the same SDK.

121
00:13:35.670 --> 00:13:47.060
So when we cover the real robot later, we won't repeat the code logic.

122
00:13:47.060 --> 00:13:53.060
We'll just focus on the physical operation steps.

123
00:13:53.060 --> 00:13:55.060
Alright, let's close all the programs.

124
00:13:55.060 --> 00:13:59.060
And that's basically everything for simulation part.

125
00:13:59.060 --> 00:14:01.060
One final important note.

126
00:14:01.060 --> 00:14:07.060
The configuration parameters used during training must match the ones in the SDK.

127
00:14:07.060 --> 00:14:18.060
That includes the observation scale, the joint Kp and Kd values, and also the default joint positions.

128
00:14:18.060 --> 00:14:25.380
And all of them need to align exactly.

129
00:14:25.380 --> 00:14:29.950
So that's the complete workflow.

130
00:14:29.950 --> 00:14:37.950
Just make sure you know where the policy files are stored and where the policy runner is located.

131
00:14:37.950 --> 00:14:42.950
You can look into the detailed code logic on your own later.

132
00:14:42.950 --> 00:14:47.950
Next, let's focus on the deployment process on the real robot.

133
00:14:47.950 --> 00:14:59.950
First, we need to prepare the DR-02 Pro robot and its battery, the gamepad controller, and your own computer for deploying the code.

134
00:14:59.950 --> 00:15:06.950
Before powering on the robot, you need to locate the hardware emergency system.

135
00:15:06.950 --> 00:15:18.950
First, press the emergency stop button and press it to trigger an emergency stop when there is any danger.

136
00:15:18.950 --> 00:15:25.420
Once the risk is cleared, twist it clockwise to release.

137
00:15:25.420 --> 00:15:35.420
Then, tap and long press the switch button to turn on the robot power.

138
00:15:35.420 --> 00:15:44.420
And finally, press the button to turn on the robot host.

139
00:15:44.420 --> 00:16:00.920
Unlike simulation deployment, real robot deployment mainly requires two repositories, SDK 2 and messages.

140
00:16:00.920 --> 00:16:10.920
So first, open the guide documentation in SDK 2 and find the real robot deployment section under Quick Start.

141
00:16:10.920 --> 00:16:18.350
This section describes the complete real robot deployment procedure.

142
00:16:18.350 --> 00:16:24.720
Here, there are currently three main deployment options.

143
00:16:24.720 --> 00:16:42.720
Deploying 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.

144
00:16:42.720 --> 00:16:51.720
Today, we will use the 103 motion control host as our example.

145
00:16:51.720 --> 00:17:08.040
First, 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.

146
00:17:08.040 --> 00:17:20.330
Then, use the scp command to transfer the SDK 2 and message's repositories to the 103 motion control host.

147
00:17:20.330 --> 00:17:33.800
Before running the command, remember to update the file path, username, and host address to match your actual setup.

148
00:17:33.800 --> 00:17:43.240
Since the files are transferred over Wi-Fi, the network conditions will affect the transfer speed.

149
00:17:43.240 --> 00:17:55.710
Generally, the closer your computer is to the robot, the faster the transfer will be.

150
00:17:55.710 --> 00:18:14.330
After the transfer is complete, use SSH to connect to the 103 motion control host, and verify that both repositories have been copied successfully.

151
00:18:14.330 --> 00:18:23.330
Next, cd into the SDK 2 folder, and run the build commands as instructed in the document.

152
00:18:23.330 --> 00:18:32.030
The guide tells us to build the messages library on the robot's motion control host first.

153
00:18:32.030 --> 00:18:40.030
The motion control host runs Ubuntu 24.04, paired with ROS2 Jazzy.

154
00:18:40.030 --> 00:18:44.690
The build process will take some time.

155
00:18:44.690 --> 00:18:49.690
While we are waiting, let's go over a few more deployment details.

156
00:18:49.690 --> 00:19:04.200
Before deployment, we need to switch the robot into developer mode.

157
00:19:04.200 --> 00:19:10.200
The developer mode mainly provides three options.

158
00:19:10.200 --> 00:19:17.200
High level motion control mode, whole body joint control mode, and upper body joint control mode.

159
00:19:17.200 --> 00:19:31.200
Since 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.

160
00:19:31.200 --> 00:19:43.480
You can enter developer mode, either with the gamepad, or by sending commands through the same sample programs provided in SDK 2.

161
00:19:43.480 --> 00:19:48.480
But in this video, we will use the gamepad for switching.

162
00:19:48.480 --> 00:19:55.480
First, turn on the gamepad, and make sure the robot is powered on and is in idle state.

163
00:19:55.480 --> 00:20:00.480
And then, we open the motion control app.

164
00:20:00.480 --> 00:20:07.480
Check the top right corner to confirm the gamepad is connected to the robot via Wi-Fi.

165
00:20:07.480 --> 00:20:24.400
Then select developer mode in the top left of the interface, and tab full body development to enter whole body joint control mode.

166
00:20:24.400 --> 00:20:35.400
To exit developer mode, simply tap exit development on the gamepad, and then switch back to the normal mode.

167
00:20:35.400 --> 00:20:45.310
Next, let's briefly review the gamepad mapping used by the real robot state machine.

168
00:20:45.310 --> 00:20:51.810
L1 switches the robot from idle state to zero position.

169
00:20:51.810 --> 00:20:57.810
L2 switches the robot to AMP from either zero position or mimic state.

170
00:20:57.810 --> 00:21:09.810
L1 switches from AMP to mimic state, and L2 triggers the whole body soft emergency stop.

171
00:21:09.810 --> 00:21:20.810
Finally, the red button in the upper right corner can also trigger the whole body soft emergency stop and exit developer mode.

172
00:21:20.810 --> 00:21:30.810
Please note that the exact button functions should always be verified against the actual implementation in the project.

173
00:21:30.810 --> 00:21:37.810
Now, the messages library has finished building, so we can continue with SDK 2.

174
00:21:37.810 --> 00:21:50.810
Before building, delete the old build logs and install directories in SDK 2 to prevent the previous building results from interfering with the current build.

175
00:21:50.810 --> 00:21:56.850
Then, run the two commands shown here.

176
00:21:56.850 --> 00:22:10.090
Here, select dr02pro as the package and set the build platform to ARM.

177
00:22:10.090 --> 00:22:14.090
Now, wait for the build to finish.

178
00:22:14.090 --> 00:22:26.880
Once the build is complete, follow the instructions in the state machine guide to source the ROS2 and SDK 2 environments.

179
00:22:26.880 --> 00:22:35.450
Then, launch the state machine program.

180
00:22:35.450 --> 00:22:48.960
When the terminal displays the corresponding start-up messages, it indicates that the program has started successfully.

181
00:22:48.960 --> 00:22:53.960
First, press L1 to move the robot into the low position.

182
00:22:53.960 --> 00:23:06.100
Okay, and before proceeding, make sure the robot's posture is stable and both feet are properly on the ground.

183
00:23:06.100 --> 00:23:14.120
Then, you can switch to AMP or mimic policy as needed.

184
00:23:14.120 --> 00:23:21.120
When deploying on a real robot, there are several safety precautions that require special attention.

185
00:23:21.120 --> 00:23:29.120
First, before running the control program, make sure the robot has entered the correct develop mode.

186
00:23:29.120 --> 00:23:33.120
Second, make sure there is enough space around the robot.

187
00:23:33.120 --> 00:23:37.120
Keep people and obstacles outside its range of motion.

188
00:23:37.120 --> 00:23:51.460
Third, before switching from zero position to policy control, confirm that the robot is standing steadily and both feet are firmly on the ground.

189
00:23:51.460 --> 00:24:10.240
Fourth, there must be only one active control command publisher at a time.

190
00:24:10.240 --> 00:24:15.240
This prevents multiple programs from controlling the robot simultaneously.

191
00:24:15.240 --> 00:24:28.240
Fifth, if the robot moves abnormally or there is any other safety risk, use the gamepad emergency stop immediately.

192
00:24:28.240 --> 00:24:34.240
Or use the hardware emergency stop button if necessary.

193
00:24:34.240 --> 00:24:42.240
Once we've confirmed that the deployment environment is safe, just press L2 to enter the AMP policy.

194
00:24:42.240 --> 00:24:50.300
Then, you can use the gamepad joystick to control the movement.

195
00:24:50.300 --> 00:24:56.300
The left joystick controls forward, backward, left, and right motion.

196
00:24:56.300 --> 00:25:00.300
And the right joystick controls turning.

197
00:25:00.300 --> 00:25:32.550
Now, let's press R1 to enter the mimic policy.

198
00:25:32.550 --> 00:25:42.540
As you can see, the robot is performing the fifth routine motion.

199
00:25:42.540 --> 00:25:49.540
And once the mimic motion finishes, the robot automatically switches back to the AMP policy.

200
00:25:49.540 --> 00:26:01.680
After we are done running the policy, first press R2 to put the robot into the soft emergency stop state.

201
00:26:01.680 --> 00:26:08.410
And confirm that the robot has stopped moving.

202
00:26:08.410 --> 00:26:15.810
And then, press Ctrl-C to terminate the motion control program.

203
00:26:15.810 --> 00:26:23.380
Next, exit the developer mode and switch back to the normal mode.

204
00:26:23.380 --> 00:26:30.890
Finally, power off the robot host.

205
00:26:30.890 --> 00:26:40.230
And then, tap and non-press the switch button to turn off the battery power.

206
00:26:40.230 --> 00:26:47.240
And that all wraps up our full real robot deployment process.

207
00:26:47.240 --> 00:26:55.240
That covers the deployment process for DR-02 Pro motion control policies from simulation to the real robot.

208
00:26:55.240 --> 00:27:04.240
And we've covered how to build and run the simulation environment, switch between and replace AMP and mimic policies,

209
00:27:04.240 --> 00:27:12.240
and deploy the policies on the real robot while following the necessary safety procedures.

210
00:27:12.240 --> 00:27:15.240
The related projects are open source now.

211
00:27:15.240 --> 00:27:24.240
You can find the SDK 2 simulation message repositories and more detailed installation and troubleshooting instructions

212
00:27:24.240 --> 00:27:29.240
through the link in the video description.

213
00:27:29.240 --> 00:27:37.240
Feel free to clone our repositories on GitHub and try deploying and testing your own trained motion control policies.

214
00:27:37.240 --> 00:27:41.240
Thank you for watching, and see you in the next video.
