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

Post by DannyYeong » 11 May 2015, 17:03

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?)

   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)

coppelia
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: Mimic Thrust Force Model - Cuboid

Post by coppelia » 11 May 2015, 20:02

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

Post by DannyYeong » 13 May 2015, 17:12

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

	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?

Post Reply