EvoTrace#

class EvoTrace#

A class to control tracing behavior using two color sensors and two motors.

Initialisation & Setup

EvoTrace::EvoTrace(EvoRGBColorSensor *leftSensor, EvoRGBColorSensor *rightSensor, EvoMotor *leftMotor, EvoMotor *rightMotor)#

Constructor to initialize the EvoTrace object.

Parameters:
  • leftSensor – Pointer to the left color sensor.

  • rightSensor – Pointer to the right color sensor.

  • leftMotor – Pointer to the left motor.

  • rightMotor – Pointer to the right motor.

void EvoTrace::begin()#

Initializes the sensors and motors.

Control Functions

void EvoTrace::PDTrackOn(int speed, float kp, float kd, TraceMode mode, int ThV)#

Starts the PD tracking behavior.

Parameters:
  • speed – The speed of the motors.

  • kp – The proportional gain.

  • kd – The derivative gain.

  • mode – The mode of operation.

  • ThV – The threshold value.

void EvoTrace::PDTrackDegrees(int speed, float kp, float kd, int degrees, TraceMode mode = BOTH_FOLLOWER, int Thv = 0, bool brake = true)#

Tracks a specified number of degrees.

Parameters:
  • speed – The speed of the motors.

  • kp – The proportional gain.

  • kd – The derivative gain.

  • degrees – The number of degrees to track.

  • mode – The mode of operation (default: BOTH_FOLLOWER).

  • Thv – The threshold value (default: 0).

  • brake – Whether to brake at the end of tracking (default: true).

void EvoTrace::PDTrackJunction(int speed, float kp, float kd, int threshold, int maxJunctions, TraceMode mode = BOTH_FOLLOWER, int Thv = 0, bool brake = true)#

Tracks junctions based on sensor readings.

Parameters:
  • speed – The speed of the motors.

  • kp – The proportional gain.

  • kd – The derivative gain.

  • threshold – The threshold value for junction detection.

  • maxJunctions – The maximum number of junctions to track.

  • mode – The mode of operation (default: BOTH_FOLLOWER).

  • Thv – The threshold value (default: 0).

  • brake – Whether to brake at the end of tracking (default: true).