using the function
Code: Select all
local pathPts,times=sim.generateTimeOptimalTrajectory(path,lengths,minMaxVel,minMaxAccel)
Code: Select all
779: attempt to index a nil value (field 'qs')
stack traceback:
...rar/CoppeliaSim_Edu_V4_6_0_rev18_Ubuntu20_04/lua/sim.lua:779: in function 'sim.generateTimeOptimalTrajectory'
here is the inputs given to the function
Code: Select all
local minMaxVel={-maxVel[1],maxVel[1],-maxVel[2],maxVel[2],-maxVel[3],maxVel[3],-maxVel[4],maxVel[4],-maxVel[5],maxVel[5],-maxVel[6],maxVel[6]}
local minMaxAccel={-maxAccel[1],maxAccel[1],-maxAccel[2],maxAccel[2],-maxAccel[3],maxAccel[3],-maxAccel[4],maxAccel[4],-maxAccel[5],maxAccel[5],-maxAccel[6],maxAccel[6]}
path,lengths=findPath(getConfig(),configs)
Code: Select all
function getPathLength(path)
-- Returns the length of the path in configuration space
local d=0
local l=#simJointHandles
local pc=#path/l
for i=1,pc-1,1 do
local config1={path[(i-1)*l+1],path[(i-1)*l+2],path[(i-1)*l+3],path[(i-1)*l+4],path[(i-1)*l+5],path[(i-1)*l+6]}
local config2={path[i*l+1],path[i*l+2],path[i*l+3],path[i*l+4],path[i*l+5],path[i*l+6]}
d=d+getConfigConfigDistance(config1,config2)
end
print(d)
return d
end
function generatePathLengths(path)
-- Returns a table that contains a distance along the path for each path point
local d=0
local l=#simJointHandles
local pc=#path/l
local retLengths={0}
for i=1,pc-1,1 do
local config1={path[(i-1)*l+1],path[(i-1)*l+2],path[(i-1)*l+3],path[(i-1)*l+4],path[(i-1)*l+5],path[(i-1)*l+6],path[(i-1)*l+7]}
local config2={path[i*l+1],path[i*l+2],path[i*l+3],path[i*l+4],path[i*l+5],path[i*l+6],path[i*l+7]}
d=d+getConfigConfigDistance(config1,config2)
retLengths[i+1]=d
end
return retLengths
end
function _findPath(startConfig,goalConfigs)
local task=simOMPL.createTask('task')
simOMPL.setAlgorithm(task,simOMPL.Algorithm.RRTConnect)
simOMPL.setStateSpaceForJoints(task,simJointHandles,useForProjection)
simOMPL.setCollisionPairs(task,{robotCollection,sim.handle_all})
simOMPL.setStartState(task,startConfig)
simOMPL.setGoalState(task,goalConfigs[1])
for i=2,#goalConfigs,1 do
simOMPL.addGoalState(task,goalConfigs[i])
end
simOMPL.setup(task)
local l=nil
local res,path=simOMPL.compute(task,maxOMPLCalculationTime,-1,200)
if path then
l=getPathLength(path)
end
simOMPL.destroyTask(task)
return path,l
end
function findPath(startConfig,goalConfigs)
-- This function will search for a path between the specified start configuration,
-- and several of the specified goal configurations.
local onePath,onePathLength=_findPath(startConfig,goalConfigs)
return onePath,generatePathLengths(onePath)
end