Problem in using ZeroMQ library from CoppeliaSim in Matlab

조회 수: 21 (최근 30일)
Farzad Torabi
Farzad Torabi 2022년 11월 20일
답변: Himanshu 2023년 8월 31일
Hi All
runnign commands using ZeroMQ in Matlab to pilot CoppeliaSim has turned with this error :
Output argument "varargout{2}" (and possibly others) not assigned a value in the execution with "RemoteAPIObject/subsref"
function.
Error in VrepConnectorZMQ (line 21)
[~,obj.robot_joints(i)] = obj.sim.getObject(strcat('/LBR_iiwa_14_R820_joint',int2str(i)));
Error in main (line 78)
robot = VrepConnectorZMQ();
The class code was :
classdef VrepConnectorZMQ
properties
sim; %Similar to fd
client; %Used for server connection and server requests
robot_joints = [] %List of joint handles
%Integration step used for simulation
end
methods
function obj = VrepConnectorZMQ()
addpath vrep_lib/; %Adding the APIs to the path
client = RemoteAPIClient();
client.setStepping(true);
obj.sim = client.getObject('sim'); %RemoteAPI object
obj.sim.startSimulation();
for i = 1:7
[~,obj.robot_joints(i)] = obj.sim.getObject(strcat('/LBR_iiwa_14_R820_joint',int2str(i)));
end
for i = 1:7
[~, joint_pos] = obj.sim.getJointPosition(obj.robot_joints(i));
end
% When simulation is not running, ZMQ message handling could be a bit
% slow, since the idle loop runs at 8 Hz by default. So let's make
% sure that the idle loop runs at full speed for this program:
defaultIdleFps = sim.getInt32Param(sim.intparam_idle_fps);
sim.setInt32Param(sim.intparam_idle_fps, 0);
end
and in the main file it was only called :
robot = VrepConnectorZMQ();

답변 (1개)

Himanshu
Himanshu 2023년 8월 31일
Hello Farzad,
I understand that you are facing an error related to the "Output argument not assigned a value" in your MATLAB code when attempting to run commands using ZeroMQ to control CoppeliaSim.
The error occurs because you are not capturing the output of the "obj.sim.getObject" function call.
To fix this issue, you need to properly capture the output of the "obj.sim.getObject" function and ensure that all required output arguments are assigned values. Since you are assigning values to elements of "robot_joints", make sure to initialize it as an array before the loop.
% initialize robot_joints array
obj.robot_joints = zeros(1, 7);
for i = 1:7
[~, obj.robot_joints(i)] = obj.sim.getObject(strcat('/LBR_iiwa_14_R820_joint', int2str(i)));
end
I hope this helps.

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by