Problem in using ZeroMQ library from CoppeliaSim in Matlab
14 次查看(过去 30 天)
显示 更早的评论
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();
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!