Control Cartesian Position of KINOVA Gen3 Robot End-Effector Using Inverse Kinematics Block and KINOVA KORTEX System Object
This example shows how to solve inverse kinematics problems using Rigid Body Trees and how to control the KINOVA® Gen3 7-DoF Ultralightweight Robot Arm to follow the desired trajectory.
Robotics System Toolbox™ Support Package for Manipulators enables you to control manipulators using MATLAB and Simulink. This support package utilizes APIs provided by robot manufactures to acquire various sensor data, simulate robot models, and to control the robot. Prototype algorithms and perform simulations of these robots using rigid body tree models from Robotics System Toolbox™ or Simscape™ Multibody™ robot models. Connect with the robot hardware to test and validate your algorithms.
In this example, the InverseKinematics System object™ from Robotics System Toolbox™ is used to calculate the actuator joint angles for the specified cartesian pose. The InverseKinematics System object™ creates an inverse kinematic (IK) solver to calculate joint configurations for a desired end-effector pose based on a specified rigid body tree model.
If you are new to Simulink, watch the Simulink Quick Start.
Perform the initial Setup and Configuration of the support package using Hardware Setup screens.
Refer to Connect to Kinova Gen3 Robot and Manipulate the Arm using MATLAB for information on the communication interface between MATLAB and the robot.
Refer to Control KINOVA Gen3 Robotic Manipulator Using KINOVA KORTEX System Object and Simulink for more information on the KORTEX™ system object from KINOVA Robotics.
To open the example model, run this command at the MATLAB prompt:
The inverseKinematics System object™ creates an inverse kinematic (IK) solver to calculate joint configurations for a desired end-effector pose based on a specified rigid body tree model. Create a rigid body tree model for your robot using the rigidBodyTree class. This model defines all the joint constraints that the solver enforces. If a solution is possible, the joint limits specified in the robot model are obeyed.
The Setpoint Control subsystem takes the desired cartesian position and pose of the end-effector of the robot and applies a coordinate transformation to generate the desired for the Inverse Kinematics block. In this example, the desired orientation of the end-effector is fixed, and the cartesian position is controlled via three input sliders. The subsystem also contains the VR sink block from Simulink 3D Animation™ for the animation of the robot.
Robot Visualization and Command Actual Robot
Robot Visualization block from Simulink 3D Animation™ enables visualization of Robotics System Toolbox™ RigidBodyTree objects in Simulink. The command actual robot subsystem uses Kortex system object from KINOVA Robotics to connect and control the Gen3 robot.
Run the model
Note: The robot will move according to the specified input, so please have the E-STOP close to you. Ensure that 'Move Robot' toggle switch is in off position before running the model. This will prevent the sudden and unintended motion of the robot.
After configuring the robot specific parameter in the Kortex system object properties, navigate to the SIMULATE tab and press Run. The simulated robot will move to the position specified by the slider position, and any change in the slider position will be reflected in the end-effector position of the simulated robot.
After validating the joint configuration generated by the inverse kinematic block, change 'Move Robot' toggle switch to on position. This will send the joint angles generated by the inverse kinematic block to the robot.
Run the Model without Simulink 3D Animation™
In the absence of Simulink 3D Animation™, this model can still be used to control the Gen3 robot. Comment out the Robot Visualization block and VR sink block in 'Setpoint Control' subsystem before running the model without valid installation of Simulink 3D Animation™. However, validate the joint configuration generated by the inverse kinematic block using display or scope blocks before sending it to the actual robot.