Hello, I am working on reinforcement learning using CoppeliaSim and MATLAB. Environment.m is a class for the reinforcement learning environment. When I call FARM_T=sim.getJointForce(jointHandle(12)); within the class, I encounter the following error:
Error using rl.train.SeriesTrainer/run
There was an error executing the environment's step method.
Caused by:
Output argument "varargout{1}" (and possibly others) not assigned a value in the execution with
"RemoteAPIObject/subsref" function.
Error in Environment/step (line 174)
FARM_T=sim.getJointForce(jointHandle(12));
Error in rl.env.MATLABEnvironment>@(a)step(env,a) (line 89)
stepfcn = @(a) step(env,a);
Error in rl.env.internal.MATLABFunctionHandleSimulator/step_ (line 22)
[next_observation,reward,isdone] = feval(this.StepFcn_,action);
Error in rl.env.internal.MATLABSimulator/step (line 15)
[next_observation,reward,isdone] = step_(this,action);
Error in rl.env.internal.MATLABSimulator/simInternal_ (line 113)
[nobs,rwd,isd] = step(this,act);
Error in rl.env.internal.MATLABSimulator/sim_ (line 67)
out = simInternal_(this,simPkg);
Error in rl.env.internal.AbstractSimulator/sim (line 30)
out = sim_(this,simData,policy,processExpFcn,processExpData);
Error in rl.env.AbstractEnv/runEpisode (line 144)
out = sim(simulator,simData,policy,processExpFcn,processExpData);
Error in rl.train.SeriesTrainer/run (line 64)
out = runEpisode(...
Error in rl.train.TrainingManager/train (line 516)
run(trainer);
Error in rl.train.TrainingManager/run (line 253)
train(this);
Error in rl.agent.AbstractAgent/train (line 187)
trainingResult = run(trainMgr,checkpoint);
Error in trainDDPGWW5 (line 112)
trainingStats = train(agent,env,trainingOptions);
I have used this code before for reinforcement learning without encountering this issue. This time, I only added some code, including FARM_T=sim.getJointForce(jointHandle(12));, and now the error occurs. However, calling FARM_P=sim.getJointPosition(jointHandle(12)); and FARM_V=sim.getJointVelocity(jointHandle(12)); does not trigger the error. Moreover, this error occurs randomly, not necessarily at the beginning of a specific episode. How can I solve this issue?