How to Send Joint Velocity Commands to Kinova Gen3 in Simulink Using KORTEX SDK?

9 views (last 30 days)

Hello,

I am currently working on implementing a closed-loop IBVS (Image-Based Visual Servoing) control for a Kinova Gen3 robotic arm in Simulink. I calculate joint velocities using a PID-based visual servo control law and would like to send these velocities directly to the robot.

I am following the example from the Connect to Kinova Gen3 from Simulink demo (link: (https://www.mathworks.com/help/robotics/robotmanipulator/ug/connect-gen3-simulink.html), which uses two System objects: 1. TrajectoryFeeder 2. KORTEX Main (provided via kortex.m from Kinova's SDK)

From what I understand, the kortex.m interface currently supports: 1. SendJointAngles 2. SendPreComputedTrajectory

However, it does not include a method like SendJointSpeeds() to send joint velocities directly.

My Questions: 1. Should I extend kortex.m to add a method like the following to send joint velocities?

function [isOk] = SendJointSpeeds(obj, joint_vel_cmd) if coder.target('MATLAB') [result] = kortexApiMexInterface('SendJointSpeeds', obj.apiHandle, joint_vel_cmd); isOk = result == KortexErrorCodes.SUB_ERROR_NONE; else result = coder.ceval('kapi_SendJointSpeeds', obj.apiHandle, ... coder.ref(joint_vel_cmd), uint32(obj.nbrJointActuators)); isOk = result == KortexErrorCodes.SUB_ERROR_NONE; end end

2. Or instead, should I use the existing SendPreComputedTrajectory() function by:

Setting position(:, i+1) = position(:, i) + velocity(:, i) * dT; Keeping acceleration as zeros Setting a fixed dT and corresponding timestamp_sec array

I would appreciate any guidance on which approach is preferred, especially for real-time deployment or when using code generation.

Thanks in advance!

Best Regards,

Answers (1)

Shishir Reddy
Shishir Reddy on 24 Jun 2025
Hi Sanket
The current 'kortex.m' interface from the Simulink example does not include a method to send joint velocities directly, which is essential for real-time IBVS (Image-Based Visual Servoing).
Since your control law outputs joint velocities, the best approach is to extend the 'kortex.m' System object to include a method like 'SendJointSpeeds' as shown below.
function [isOk] = SendJointSpeeds(obj, joint_vel_cmd)
if coder.target('MATLAB')
% Use MEX interface during simulation
[result] = kortexApiMexInterface('SendJointSpeeds', ...
obj.apiHandle, joint_vel_cmd);
isOk = result == KortexErrorCodes.SUB_ERROR_NONE;
else
% For code generation (Simulink Real-Time, etc.)
result = coder.ceval('kapi_SendJointSpeeds', ...
obj.apiHandle, ...
coder.ref(joint_vel_cmd), ...
uint32(obj.nbrJointActuators));
isOk = result == KortexErrorCodes.SUB_ERROR_NONE;
end
end
This allows you to send joint velocity commands directly to the robot using Kinova’s low-level API.
For more information, kindly refer the following example - https://www.mathworks.com/help/robotics/robotmanipulator/ug/connect-gen3-simulink.html
I hope this helps.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!