## QuadriCopter - How to control motors

Typically: "How do I... ", "How can I... " questions
Posts: 6
Joined: 09 Sep 2014, 09:51

### QuadriCopter - How to control motors

Hey i am noob with V-Rep so sorry for stupid question but how can i control Quadricopter's motors?
I read Quadricopter's default script and they did it with simAddForceAndTorque isn't there easier way for example cannot i use simSetJointTargetVelocity? I tried use simSetJointTargetVelocity but it didn't work. I'm just asking if there is a easier way to set motor's velocity and not only the QuadriCopter_target.

Thanks

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

### Re: QuadriCopter - How to control motors

Hello,

the quadricopter is working like follows:
• for each rotor, an artificial force is generated. This is the thrust. This is done with simAddForceAndTorque. This is what makes the quadricopter fly.
• for each rotor, a joint velocity is set (with simSetJointTargetVelocity), in order to have the rotor rotate. The rotation is just eye candy, i.e. it has no functional effect
• for each rotor, particles are emitted towards the ground, in order to emulate the wind effect. This has no influence on the movement of the quadricopter, unless it is very close to the ground and the particles bounce back and touch the quadricopter)
Cheers

Posts: 6
Joined: 09 Sep 2014, 09:51

### Re: QuadriCopter - How to control motors

I won't mess around with ForceAndTorque. I will modify quadricopter's script and only change thrust values instead.

Code: Select all

-- Decide of the motor velocities:
particlesTargetVelocities[1]=thrust*(1-alphaCorr+betaCorr+rotCorr)
particlesTargetVelocities[2]=thrust*(1-alphaCorr-betaCorr-rotCorr)
particlesTargetVelocities[3]=thrust*(1+alphaCorr-betaCorr+rotCorr)
particlesTargetVelocities[4]=thrust*(1+alphaCorr+betaCorr-rotCorr)

or should i use write own scripts and calculate own values for simAddForceAndTorque?

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

### Re: QuadriCopter - How to control motors

The easiest would be to remove all child scripts, except the one that is attached to the base of the model. In there, simply compute the 4 thrusts you wish, and apply them with simAddForceAndTorque. This would be the most straight-forward method.

Cheers

Posts: 6
Joined: 09 Sep 2014, 09:51

### Re: QuadriCopter - How to control motors

I will give it a try, but i am total noob in v-rep universe so we will probably meet again :D :D
Anyway thank you very much.

kemz
Posts: 6
Joined: 07 Jul 2019, 15:48

### Re: QuadriCopter - How to control motors

Hi Copellia,
I have successfully applied the force to keep the quadrotor floating, how do I move it forward ?

coppelia