Main Content

Manipulate Individual Joint Angle Using MATLAB

This section helps you to manipulate individual joint angle of the KINOVA® Gen3 7-DoF Ultralightweight Robot arm using MATLAB®. Execute these commands sequentially in the MATLAB to manipulate individual joint angles of the robot. As explained in KINOVA github page, the first part of the ROS topic, 'my_gen3’ might be different based on the robot name set during the roslaunch command.

Create a service client with an empty message to control the individual joint angles.

[jointSrv,jointRequest] = rossvcclient('/my_gen3/base/play_joint_trajectory');

Set the desired joint angles for Kinova® Gen3 robot.

jAngs = [0 15 180 -130 0 55 90]'*pi/180;
jAngs(jAngs < 0) = jAngs(jAngs < 0) + 2*pi;

Populate the blank message with the desired joint angle values.

for idx = 1:7
    jAngMsgs(idx) = rosmessage('kortex_driver/JointAngle');
    jAngMsgs(idx).JointIdentifier = idx;
    jAngMsgs(idx).Value = rad2deg(jAngs(idx));
end
jointRequest.Input.JointAngles.JointAngles_ = jAngMsgs;

Use the default type and value for the constraints. This will set the constraint type to angular velocity constraint and uses the default limit for the maximum Angular velocity.

jointRequest.Input.Constraint.Type = 0;    % Speed constraint
jointRequest.Input.Constraint.Value = 0;  % Max angular speed in deg/s

Call the service to move the Robot.

call(jointSrv,jointRequest);

Wait for the robot to stop moving.