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

13 visualizzazioni (ultimi 30 giorni)

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,

Risposte (1)

Shishir Reddy
Shishir Reddy il 24 Giu 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.
  1 Commento
Sakshi
Sakshi circa 6 ore fa
Hi!
Thank you! The above explanation is really helpful.
I am modifying the example from the “Connect to Kinova Gen3 from Simulink” demo (link: https://www.mathworks.com/help/robotics/robotmanipulator/ug/connect-gen3-simulink.html) , in acordance with that, to integrate an IBVS control loop that outputs joint velocities, which I want to send directly to the robot.
I tried sending joint angle commands but that results in an extremly slow and jerky robot motion.
My understanding is that I will need to:
  1. Modify the WaypointFeeder System object to accept dynamically changing joint velocity commands instead of position waypoints.
  2. Extend the Kortex command enumeration to include joint velocity command types.
  3. Update the kortex.m System object so it can transmit these velocity commands to the Kinova Gen3 using the appropriate Kortex API fields.
Before proceeding, I would like help with two points:1. Simulation Challenge
The VR Rigid Body block in the example does not accept joint velocity inputs.
Is there a way to use the Kinova Gen3 rigid body model (from the Robotics System Toolbox) to simulate the robot’s behavior when driven by joint velocity commands?
2. Validation of Approach
Can you help me unerstand the correct approach to modifying the System objects (WaypointFeeder + kortex.m) to send joint velocity commands is the correct approach for controlling the real Gen3 in velocity mode? I unerstand the I will have to modify WaypointFeeder to accept joint velocities, modify the enumCmd.m code to add the joint veloity parameter apaert from adding the piece of code you mentioned in kortex.m sstem object.
I want to ensure I’m not misunderstanding the Kortex API structure, and I want to avoid sending incorrect message types that could cause unsafe robot behavior.

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by