Example 1: Robot Arm Simulation with Regular PD Controller - ihmcrobotics/ihmc-open-robotics-software-tutorials GitHub Wiki
Introduction
Before introducing the IHMC whole-body controller core, let's go through an example without it. The goal here, now that we have worked with the simulation environment SCS, is to introduce the basic concepts behind writing a robot controller. We will implement and manipulate a series of simple joint feedback controllers to control the joint positions of a 7-DoF (Degrees of Freedom) robot arm.
To understand a bit more about degrees of freedom and robot arm movement, I invite you to watch this short video on the topic.
Understanding the Contents of the Project
Now let's look at the robot-arm-one
project. It contains the "meat" of this example. There are four Java files here:
RobotArmOneDefinition.java
, which declares theRobotArmOneDefinition
class. This class defines the robot arm model, which has a fixed base and 7 degrees of freedom. It defines all the joints and links and how they are connected.RobotArmOneController.java
, which declares the feedback controller for the robot arm.RobotArmOneSimulation.java
, which declares the simulation entrypoint. This sets up an SCS instance to simulate theRobotArmOne
model with theRobotArmOneController
set up for feedback control.SevenDoFArmParameters.java
, which defines several physical parameters for the robot arm model, such as mass properties and kinematic information.
For a more thorough explanation, I invite you to read through the code in the files. The code in each project of this tutorial has been notated heavily for user clarification, and to fully understand how the controllers work, it would be good practice to read through the provided class files before or after running the simulations.
Run the Simulation
Similarly to how we ran the Mobile simulation, open the RobotArmOneSimulation
class, right-click in the code editor, and go down to Run As > Java Application:
SCS should launch after a moment and present you with the simulation GUI. If you press the Simulate button
you should see something similar to this:
Similar to the simple pendulum with controller example, we have a controller class: RobotArmOneController
, which implements the interface Controller
, which controls the robot arm movement. The Controller.doControl()
method is called every simulation tick, which can be implemented to do Proportional-Derivative (PD) control on each joint separately to calculate the position, velocity, acceleration, and torque of each joint. In this example, these PD controllers are used to get the shoulder yaw joint and the elbow pitch joint to follow two sine wave trajectories.
Experiment with the Simulation
Feel free to play with some of the parameters. Click on the button shown below to create a desired number of empty graphs.
Extend the variable and registry section by clicking on the three red lines on the top left of the window and add variables to the graphs using drag and drop. Plot the desired and the actual shoulder yaw joint angle. Look for the variables desiredPositionShoulderYaw
and q_shoulderYaw
and drag them to the new plot. They both should describe a sine wave with the joint angle closely following the desired value.
Next, look for the variable kpShoulderYaw
and reduce it by a factor of 10
. You should see the tracking get worse as you decrease the gain. You can also change the value of kdShoulderYaw
.
Notice the performance of the controller. Some of the variables are not well tracked using this regular PD controller:
Once you're ready, let's move onto the next example which introduces the IHMC whole-body controller core Example 2: Using the IHMC Whole Body Controller Core to Control the Robot Arm in Joint Space.