coppelia wrote:You are using a simple 2-state controller. Either you apply a force of X, or a force of Y. It is normal that your control won't be good. You will have to use something more sofisticated, at least a P/PD controller. You will have to try.

Cheers

How the "5" was determined in the derivative part of the drag control?

-- str is the derivative paramter of the PD controller
local str=-5 -- drag (how was it determined?)
simAddForceAndTorque(propeller,{0,0,-accel[3]*cm})
local linV,angV=simGetVelocity(propeller)
local mass=simGetShapeMassAndInertia(propeller)
local f={linV[1]*mass*str*cm,linV[2]*mass*str*cm,linV[3]*mass*str*cm}
simAddForceAndTorque(propeller,f)

if (sim_call_type==sim_childscriptcall_initialization) then
body=simGetObjectHandle('Quad_Body')
pos1={0,0,0.5}
end
if (sim_call_type==sim_childscriptcall_actuation) then
pos=simGetObjectPosition(body,-1)
grav=simGetArrayParameter(sim_arrayparam_gravity)
mass,inertia=simGetShapeMassAndInertia(body)
diff=pos1[3]/pos[3]-- >1 shows over extended, <1 shows under extended
if diff>1 then -- upward force
f={0,0,-grav[3]*mass*1.01} -- to overcome the gravity force
simAddForceAndTorque(body,f)
vel=simGetVelocity(body)
f={0,0,mass*vel[3]*-0.8} -- velocity vector to counter inertia oppositely
simAddForceAndTorque(body,f)
end
if diff<1 then -- downward force
f={0,0,-grav[3]*mass*0.99}
simAddForceAndTorque(body,f)
end
end

Is this workable for future linear movements on XY axis?