Main Content

Test Basic Connection and Move the Wrist Joint

After you perform the initial configuration activities as described in Set Up Network Adapter and Basic Network Ping and for Kinova® Gen3, you can test the basic connection with the robot and try to move the wrist joint of the robot.

Create Robot APIs Wrapper

To create a wrapper for MATLAB® APIs for using with the Gen 3 robot:

  1. Import enums and structures.

    Simulink.importExternalCTypes(which('kortex_wrapper_data.h')); 
  2. Create an API instance to connect to the robot

    gen3 = kortex; 

    This creates an object of class kortex with default properties for IP address, user name and password.

  3. Modify the IP address of the robot

    gen3. ip_address= ‘192.168.1.10’; 
  4. Modify the user name and password

    gen3. user = ‘admin’; 
    gen3. password = ‘admin’; 
  5. Connect to the robot

    isOk = gen3.CreateRobotApisWrapper; 

    On successful connection, the function returns true.

Display Joint Angles of the Robot

[isOk, baseFeedback, jointsFeedback, interconnectFeedback] = obj.SendRefreshFeedback; 
disp(jointsFeedback.position); 

Move the Wrist Joint of the Robot

You can use the SendJointAngles command to move the robot to a particular position defined by a set of joint angles. Because the Kinova® Gen 3 robot has seven actuators, the input to the function is a vector of size 1-by-7. The valid range of joint angle is 0 to 360 degrees.

In the previous step, you read current joint angles from the robot. The following command specifies that the wrist joint of the actuator be moved by 5 degrees.

jointCmd = jointsFeedback.position + [0,0,0,0,0,0,5]; 

Specify constraints for the robot motion (if you specify 0, the default values are used):

constraintType = int32(0); 
speed = 0; 
duration = 0; 

Send high-level command to the robot to move the wrist joint:

isOk = gen3.SendJointAngles(jointCmd, constraintType, speed, duration);

Disconnect from the Robot

isOk = gen3.DestroyRobotApisWrapper;