Instancing Motors

The Servo init constructor has the following syntax:

  myServoObject = new Servo(myPort);

where myPort is either "A", "B" or "C". The created object makes it possible to control the motor connected to the port in parameter.

As an example, in the current TriBot.ini, three Servo objects are created :

  wheelL = new Servo("C");
  wheelR = new Servo("A");
  claw = new Servo("B");

The wheel left is on port C, the wheel right on A and the claw is on port B.

A PID control is provided with this engine in order to be able to control a motor position. You can set your own PID parameters:

  myServoObject.PGain     = 0.01;
  myServoObject.IGain     = 0.01;
  myServoObject.DGain     = 0.01;
  myServoObject.Precision = 0.01; 

Changing these parameters will change the PID behaviour. The PID control is then launched by changing the val attribute:

  myServoObject.val = myServoObject.val + 360;

Which means that the servo position will go forward of 360 degrees.

The PID control will stop when the precision you asked is reached, if you want to enable the control forever, just set the precision to 0.