Lua runtime Error

Typically: "How do I... ", "How can I... " questions
Post Reply
minisch
Posts: 40
Joined: 09 Oct 2014, 11:14

Lua runtime Error

Post by minisch » 17 Feb 2015, 14:16

Hi to all,

I am trying to simulate multiple quadrotors. The simulation is almost ok but I get this annoying error:
Image
Someone can tell me to what is it due?

Thanks.

Eric
Posts: 186
Joined: 11 Feb 2013, 16:39

Re: Lua runtime Error

Post by Eric » 17 Feb 2015, 14:39

Hi

well, you are apparently misusing the simGetObjectPosition function... my best guess is that the handle of the object you are trying to change the position is not proper... but without the code it s difficult to help you!

Cheers

Eric

minisch
Posts: 40
Joined: 09 Oct 2014, 11:14

Re: Lua runtime Error

Post by minisch » 17 Feb 2015, 17:01

Well, I am using a bridge to communicate between ROS and VREP and every quadrotor has a non-threaded child script.

Below is the code of the script. Let me know if this is enough otherwise I will look into the bridge. Which, anyway, is this one:
http://wiki.ros.org/vrep_ros_bridge

This is the script:

Code: Select all

------------------------------------------------------------------------------ 
-- Following few lines automatically added by V-REP to guarantee compatibility 
-- with V-REP 3.1.3 and later: 
if (sim_call_type==sim_childscriptcall_initialization) then 
	simSetScriptAttribute(sim_handle_self,sim_childscriptattribute_automaticcascadingcalls,false) 
end 
if (sim_call_type==sim_childscriptcall_cleanup) then 
 
end 
if (sim_call_type==sim_childscriptcall_sensing) then 
	simHandleChildScripts(sim_call_type) 
end 
if (sim_call_type==sim_childscriptcall_actuation) then 
	if not firstTimeHere93846738 then 
		firstTimeHere93846738=0 
	end 
	simSetScriptAttribute(sim_handle_self,sim_scriptattribute_executioncount,firstTimeHere93846738) 
	firstTimeHere93846738=firstTimeHere93846738+1 
 
------------------------------------------------------------------------------ 
 
 
if (simGetScriptExecutionCount()==0) then
	
		-- Put some initialization code here
	
		-- Make sure you read the section on "Accessing general-type objects programmatically"
		-- For instance, if you wish to retrieve the handle of a scene object, use following instruction:
		--
		-- handle=simGetObjectHandle('sceneObjectName')
		-- 
		-- Above instruction retrieves the handle of 'sceneObjectName' if this script's name has no '#' in it
		--
		-- If this script's name contains a '#' (e.g. 'someName#4'), then above instruction retrieves the handle of object 'sceneObjectName#4'
		-- This mechanism of handle retrieval is very convenient, since you don't need to adjust any code when a model is duplicated!
		-- So if the script's name (or rather the name of the object associated with this script) is:
		--
		-- 'someName', then the handle of 'sceneObjectName' is retrieved
		-- 'someName#0', then the handle of 'sceneObjectName#0' is retrieved
		-- 'someName#1', then the handle of 'sceneObjectName#1' is retrieved
		-- ...
		--
		-- If you always want to retrieve the same object's handle, no matter what, specify its full name, including a '#':
		--
		-- handle=simGetObjectHandle('sceneObjectName#') always retrieves the handle of object 'sceneObjectName' 
		-- handle=simGetObjectHandle('sceneObjectName#0') always retrieves the handle of object 'sceneObjectName#0' 
		-- handle=simGetObjectHandle('sceneObjectName#1') always retrieves the handle of object 'sceneObjectName#1'
		-- ...
		--
		-- Refer also to simGetCollisionhandle, simGetDistanceHandle, simGetIkGroupHandle, etc.
		--
		-- Following 2 instructions might also be useful: simGetNameSuffix and simSetNameSuffix
		quadrotor = simGetObjectAssociatedWithScript(sim_handle_self)
		quadrotorName = simGetObjectName(quadrotor)
		simExtSetIntCustomDataFromHeader(quadrotor, sim_ext_ros_bridge_quadrotor_data_ctrl_mode, sim_ext_ros_bridge_quadrotor_ctrl_mode_internal)
		simExtSetFloatCustomDataFromHeader(quadrotor, sim_ext_ros_bridge_quadrotor_data_tf_ratio, 0.01738)
		simExtSetFloatCustomDataFromHeader(quadrotor, sim_ext_ros_bridge_imu_data_mass, 1)
		simExtSetFloatCustomDataFromHeader(quadrotor, sim_ext_ros_bridge_quadrotor_tk_data_main, 0.0)
		simAddStatusbarMessage(simExtGetAllCustomData(quadrotor))
		simAddStatusbarMessage(type(0))
	
		-- Targets lines
		--target0Handle=simGetObjectHandle('Quadricopter_target_0')
		--target1Handle=simGetObjectHandle('Quadricopter_target_1')
		--target2Handle=simGetObjectHandle('Quadricopter_target_2')
		--drawingObjectHandle0 = simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic,2, 0.0,target0Handle, 1, {0,255,0},nil,nil,nil)
		--drawingObjectHandle1 = simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic,2, 0.0,target1Handle, 1, {0,255,0},nil,nil,nil)
		--drawingObjectHandle2 = simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic,2, 0.0,target2Handle, 1, {0,255,0},nil,nil,nil)

		-- Quadcopters lines
		quadrotor0Handle=simGetObjectHandle('quadrotor_0')
		quadrotor1Handle=simGetObjectHandle('quadrotor_1')
		-- quadrotor2Handle=simGetObjectHandle('quadrotor_2')
		drawingObjectHandle_0 = simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic,2, 0.0,quadrotor0Handle, 1, {255,0,0},nil,nil,nil)
		drawingObjectHandle_1 = simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic,2, 0.0,quadrotor1Handle, 1, {255,0,0},nil,nil,nil)
		-- drawingObjectHandle_2 = simAddDrawingObject(sim_drawing_lines+sim_drawing_cyclic,2, 0.0,quadrotor2Handle, 1, {255,0,0},nil,nil,nil)


	end
	
	simHandleChildScripts(sim_call_type)
	
	-- Put your main code here
	
	-- For example:
	--
	-- position=simGetObjectPosition(handle,-1)
	-- position[1]=position[1]+0.001
	-- simSetObjectPosition(handle,-1,position)
	d = simGetObjectPosition(quadrotor0Handle, -1)
	e = simGetObjectPosition(quadrotor1Handle, -1)
	f = simGetObjectPosition(quadrotor2Handle, -1)
	simAddDrawingObjectItem(drawingObjectHandle_0,{d[1],d[2],d[3],e[1],e[2],e[3]})
	simAddDrawingObjectItem(drawingObjectHandle_1,{e[1],e[2],e[3],f[1],f[2],f[3]})
	simAddDrawingObjectItem(drawingObjectHandle_2,{f[1],f[2],f[3],d[1],d[2],d[3]})	



	if (simGetSimulationState()==sim_simulation_advancing_lastbeforestop) then
	
		-- Put some restoration code here
	
	end
	
 
 
------------------------------------------------------------------------------ 
-- Following few lines automatically added by V-REP to guarantee compatibility 
-- with V-REP 3.1.3 and later: 
end 
------------------------------------------------------------------------------ 

Eric
Posts: 186
Joined: 11 Feb 2013, 16:39

Re: Lua runtime Error

Post by Eric » 17 Feb 2015, 17:59

hi

could you verify the value of quadrotor2Handle? with a print("quadrotor2Handle:",quadrotor2Handle) after line 92 of one of the scripts... I m pretty sure it will be nil meaning that the object quadrotor_2 does not exists.

Post Reply