QuadriCopter - How to control motors

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

QuadriCopter - How to control motors

Post by QuadJA » 04 Jan 2015, 18:40

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
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: QuadriCopter - How to control motors

Post by coppelia » 05 Jan 2015, 18:32

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

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

Re: QuadriCopter - How to control motors

Post by QuadJA » 06 Jan 2015, 00:20

Thank you for your reply it is really helpful, and i would like to hear your opinion on which way is better:
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
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: QuadriCopter - How to control motors

Post by coppelia » 06 Jan 2015, 22:40

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

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

Re: QuadriCopter - How to control motors

Post by QuadJA » 07 Jan 2015, 17:21

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

Post by kemz » 21 Jul 2019, 13:58

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

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

Re: QuadriCopter - How to control motors

Post by coppelia » 29 Jul 2019, 10:07

Now you can add small delta force values to make your quadcopter move up, down, sideways, etc. You might have to include them in an appropriate controller..

Cheers

Post Reply