Main Content

Load Predefined Robot Models

To quickly access common robot models, use the loadrobot function, which loads commercially available robot models like the Universal Robots™ UR10 cobot, Boston Dynamics™ Atlas humanoid, and KINOVA™ Gen 3 manipulator. Explore how to generate joint configurations and interact with the robot models.

To import your own universal robot description format (URDF), see the importrobot function.

Specify the robot model type as a string to the loadrobot function. Utilize tab completion to select from the list of provided models as inputs.

To use column vectors for joint configurations, specify the data format as "column".

ur10 = loadrobot("universalUR10");
atlas = loadrobot("atlas");
gen3 = loadrobot("kinovaGen3","DataFormat","column");

The loadrobot function returns a rigidBodyTree object that represents the kinematics and dynamics of each robot model. Some models may not load with dynamics or inertial properties for bodies. Inspect individual rigid bodies using the Bodies property or the getBody function.

disp(gen3);
  rigidBodyTree with properties:

     NumBodies: 8
        Bodies: {[1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]}
          Base: [1x1 rigidBody]
     BodyNames: {'Shoulder_Link'  'HalfArm1_Link'  'HalfArm2_Link'  'ForeArm_Link'  'Wrist1_Link'  'Wrist2_Link'  'Bracelet_Link'  'EndEffector_Link'}
      BaseName: 'base_link'
       Gravity: [0 0 0]
    DataFormat: 'column'

Call show to visualize the robot models in the home configuration. Replace the gen3 object with other models to visualize them.

show(gen3);

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 25 objects of type patch, line. These objects represent base_link, Shoulder_Link, HalfArm1_Link, HalfArm2_Link, ForeArm_Link, Wrist1_Link, Wrist2_Link, Bracelet_Link, EndEffector_Link, Shoulder_Link_mesh, HalfArm1_Link_mesh, HalfArm2_Link_mesh, ForeArm_Link_mesh, Wrist1_Link_mesh, Wrist2_Link_mesh, Bracelet_Link_mesh, base_link_mesh.

show(atlas);

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 169 objects of type patch, line. These objects represent pelvis, ltorso, mtorso, utorso, l_clav, l_scap, l_uarm, l_larm, l_ufarm, l_lfarm, l_hand, l_hand_force_torque, l_situational_awareness_camera_link, l_situational_awareness_camera_optical_frame, head, center_bottom_led_frame, center_top_led_frame, left_camera_frame, left_camera_optical_frame, left_led_frame, pre_spindle, pre_spindle_cal_x, pre_spindle_cal_y, pre_spindle_cal_z, pre_spindle_cal_roll, pre_spindle_cal_pitch, pre_spindle_cal_yaw, post_spindle, post_spindle_cal_x, post_spindle_cal_y, post_spindle_cal_z, post_spindle_cal_roll, post_spindle_cal_pitch, hokuyo_link, head_hokuyo_frame, right_camera_frame, right_camera_optical_frame, right_led_frame, r_clav, r_scap, r_uarm, r_larm, r_ufarm, r_lfarm, r_hand, r_hand_force_torque, r_situational_awareness_camera_link, r_situational_awareness_camera_optical_frame, l_uglut, l_lglut, l_uleg, l_lleg, l_talus, l_foot, r_uglut, r_lglut, r_uleg, r_lleg, r_talus, r_foot, ltorso_mesh, mtorso_mesh, utorso_mesh, l_clav_mesh, l_scap_mesh, l_uarm_mesh, l_larm_mesh, l_ufarm_mesh, l_lfarm_mesh, l_hand_force_torque_mesh, l_situational_awareness_camera_link_mesh, head_mesh, hokuyo_link_mesh, r_clav_mesh, r_scap_mesh, r_uarm_mesh, r_larm_mesh, r_ufarm_mesh, r_lfarm_mesh, r_hand_force_torque_mesh, r_situational_awareness_camera_link_mesh, l_uglut_mesh, l_lglut_mesh, l_uleg_mesh, l_lleg_mesh, l_talus_mesh, l_foot_mesh, r_uglut_mesh, r_lglut_mesh, r_uleg_mesh, r_lleg_mesh, r_talus_mesh, r_foot_mesh, pelvis_mesh.

show(ur10);

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains 28 objects of type patch, line. These objects represent world, base_link, base, shoulder_link, upper_arm_link, forearm_link, wrist_1_link, wrist_2_link, wrist_3_link, ee_link, tool0, base_link_mesh, shoulder_link_mesh, upper_arm_link_mesh, forearm_link_mesh, wrist_1_link_mesh, wrist_2_link_mesh, wrist_3_link_mesh.

Generate Joint Configurations

Generate random configurations for the KINOVA Gen3 robot. The randomConfiguration function outputs random joint positions within the limits of the model. To verify the model behaves as expected, visualize a set of four configurations.

for i = 1:4
    subplot(2,2,i)
    config = randomConfiguration(gen3);
    show(gen3,config);
end

Figure contains 4 axes objects. Axes object 1 with xlabel X, ylabel Y contains 25 objects of type patch, line. These objects represent base_link, Shoulder_Link, HalfArm1_Link, HalfArm2_Link, ForeArm_Link, Wrist1_Link, Wrist2_Link, Bracelet_Link, EndEffector_Link, Shoulder_Link_mesh, HalfArm1_Link_mesh, HalfArm2_Link_mesh, ForeArm_Link_mesh, Wrist1_Link_mesh, Wrist2_Link_mesh, Bracelet_Link_mesh, base_link_mesh. Axes object 2 with xlabel X, ylabel Y contains 25 objects of type patch, line. These objects represent base_link, Shoulder_Link, HalfArm1_Link, HalfArm2_Link, ForeArm_Link, Wrist1_Link, Wrist2_Link, Bracelet_Link, EndEffector_Link, Shoulder_Link_mesh, HalfArm1_Link_mesh, HalfArm2_Link_mesh, ForeArm_Link_mesh, Wrist1_Link_mesh, Wrist2_Link_mesh, Bracelet_Link_mesh, base_link_mesh. Axes object 3 with xlabel X, ylabel Y contains 25 objects of type patch, line. These objects represent base_link, Shoulder_Link, HalfArm1_Link, HalfArm2_Link, ForeArm_Link, Wrist1_Link, Wrist2_Link, Bracelet_Link, EndEffector_Link, Shoulder_Link_mesh, HalfArm1_Link_mesh, HalfArm2_Link_mesh, ForeArm_Link_mesh, Wrist1_Link_mesh, Wrist2_Link_mesh, Bracelet_Link_mesh, base_link_mesh. Axes object 4 with xlabel X, ylabel Y contains 25 objects of type patch, line. These objects represent base_link, Shoulder_Link, HalfArm1_Link, HalfArm2_Link, ForeArm_Link, Wrist1_Link, Wrist2_Link, Bracelet_Link, EndEffector_Link, Shoulder_Link_mesh, HalfArm1_Link_mesh, HalfArm2_Link_mesh, ForeArm_Link_mesh, Wrist1_Link_mesh, Wrist2_Link_mesh, Bracelet_Link_mesh, base_link_mesh.

Interact with Robot Model

To move the robot model around and inspect the behavior, load the interactive rigid body tree GUI. You can set target end-effector positions, manually move joints, and select various elements in your model.

interactiveGUI = interactiveRigidBodyTree(gen3);

Figure Interactive Visualization contains an axes object. The axes object with xlabel X, ylabel Y contains 35 objects of type patch, line, surface.

Click and drag the center disk to freely move the target end-effector position. The GUI uses Inverse Kinematics to solve for the joint positions of each body. Use the axes to move linearly and the circles to rotate about an axis.

Click a rigidBody to view their specific parameters.

Right-click to set a different target marker body. Changing the target body updates the end-effector of the inverse kinematics solver.

To manually control joints, right-click and toggle the marker control method.

To control the rotation of a revolute joint on the body you selected, click and drag the yellow circle.

Save Joint Configurations

Save specific configurations that you set using the addConfiguration function, which stores the current joint positions in the StoredConfigurations property. This example sets a random configuration before storing.

interactiveGUI.Configuration = randomConfiguration(gen3);

Figure Interactive Visualization contains an axes object. The axes object with xlabel X, ylabel Y contains 35 objects of type patch, line, surface.

addConfiguration(interactiveGUI)
disp(interactiveGUI.StoredConfigurations)
   -0.4218
   -1.6647
    1.3419
   -2.0818
    1.8179
   -0.4140
   -1.4517

Next Steps

Now that you built your model in MATLAB®, you may want to do many different things.

  • Perform Inverse Kinematics to get joint configurations based on desired end-effector positions. Specify additional robot constraints other than the model parameters including aiming constraints, Cartesian bounds, or pose targets.

  • Generate Trajectory Generation based on waypoints and other parameters with trapezoidal velocity profiles, B-splines, or polynomial trajectories.

  • Perform Manipulator Planning utilizing your robot models and an rapidly-exploring random tree (RRT) path planner.

  • Check for Collision Detection with obstacles in your environment to ensure safe and effective motion of your robot.

See Also

| |