## Mimic Thrust Force Model - Cuboid

Typically: "How do I... ", "How can I... " questions
DannyYeong
Posts: 44
Joined: 24 Feb 2015, 17:06

### Re: Mimic Thrust Force Model - Cuboid

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?

Code: Select all

   -- str is the derivative paramter of the PD controller
local str=-5 -- drag (how was it determined?)

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)

coppelia
Posts: 7594
Joined: 14 Dec 2012, 00:25

### Re: Mimic Thrust Force Model - Cuboid

This is an experimental value, but you could also compute it. It is the drag component.

Cheers

DannyYeong
Posts: 44
Joined: 24 Feb 2015, 17:06

### Re: Mimic Thrust Force Model - Cuboid

coppelia wrote:This is an experimental value, but you could also compute it. It is the drag component.

Cheers
Noted, here's my coding modified for it. It's not a perfect undamped state but it reaches about the target height.

here's the file: http://www.filedropper.com/fullmodel

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then

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

vel=simGetVelocity(body)
f={0,0,mass*vel[3]*-0.8} -- velocity vector to counter inertia oppositely