Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Baby Orangutan, Arduino IDE and Pololu QTR 8RC Problem


Hi friends,
I am trying to make a line-follower robot using Baby Orangutan and Pololu QTR 8RC. I am using Arduino UNO to program the Baby Orangutan. I typed the code below but I couldnt manage to work. I got errors saying “undefined reference to ‘qtr_rc_init’, undefined reference to ‘qtr_calibrate’, undefined reference to ‘qtr_read_line’”. Could you help me solve the problem?


#include <orangutan.h>  
  int Kp = 50;   
  int Kd = 2500;
  int M1 = 160;
  int M2 = 160;

  int main() 
    int lastError = 0;
    unsigned char qtr_rc_pins[]={IO_D7, IO_C5, IO_C4, IO_C3, IO_C2, IO_C1, IO_C0, IO_D4};
    int i;
    for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds
      unsigned int sensors[8];
      //int position = qtr_read_line_white(sensors, QTR_EMITTERS_ON);
      int position = qtr_read_line(sensors, QTR_EMITTERS_ON);
      int error = position - 1000;
      int motorSpeed = Kp * error + Kd * (error - lastError);
      lastError = error;
      int m1Speed = M1 + motorSpeed;
      int m2Speed = M2 - motorSpeed;
      if (m1Speed < 0)
        m1Speed = 0;
      if (m2Speed < 0)
        m2Speed = 0;
      // set motor speeds using the two motor speed variables above
    return 0;



It looks like you are getting that error because you did not include the QTR library at the top of your program. Adding #include <PololuQTRSensors.h> to the top of the code should get rid of the error if you have the QTR library installed.