Multiple definitions error message in OSEPP example code

Hi all,

I’ve bought an OSEPP Robotics Kit and have been trying to compile the example code that came with it to make it run. I’ve searched for a solution and have a general understanding of the “multiple definitions error” but can’t seem to understand where this particular error is coming from. Attached are the project files and I’ve copied the error code below. I don’t get any errors until the linking phase of the compile. I’m sure its a fairly easy fix, and I apologize but I’m just trying to learn. Thank you all for your time.

Arduino: 1.8.12 (Linux), Board: “Arduino Uno”

/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/irfollower.cpp.o (symbol from plugin): In function IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)’
/tmp/arduino_build_148969/sketch/irfollower.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/irfollower.cpp.o (symbol from plugin): In function IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)’
/tmp/arduino_build_148969/sketch/irfollower.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/irfollower.cpp.o (symbol from plugin): In function IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of IRFollower::readDegrees()’
/tmp/arduino_build_148969/sketch/irfollower.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/irfollower.cpp.o (symbol from plugin): In function IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of IRFollower::forwardWeight’
/tmp/arduino_build_148969/sketch/irfollower.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/irfollower.cpp.o (symbol from plugin): In function IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of IRFollower::innerWeight’
/tmp/arduino_build_148969/sketch/irfollower.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/irfollower.cpp.o (symbol from plugin): In function IRFollower::IRFollower(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of IRFollower::cornerWeight’
/tmp/arduino_build_148969/sketch/irfollower.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/motor.cpp.o (symbol from plugin): In function Motor::Motor(unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of Motor::Motor(unsigned char, unsigned char, unsigned char)’
/tmp/arduino_build_148969/sketch/motor.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/motor.cpp.o (symbol from plugin): In function Motor::Motor(unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of Motor::Motor(unsigned char, unsigned char, unsigned char)’
/tmp/arduino_build_148969/sketch/motor.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/motor.cpp.o (symbol from plugin): In function Motor::Motor(unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of Motor::forward(unsigned char)’
/tmp/arduino_build_148969/sketch/motor.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/motor.cpp.o (symbol from plugin): In function Motor::Motor(unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of Motor::backward(unsigned char)’
/tmp/arduino_build_148969/sketch/motor.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/motor.cpp.o (symbol from plugin): In function Motor::Motor(unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of Motor::brake()’
/tmp/arduino_build_148969/sketch/motor.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/arduino_build_148969/libraries/OSEPP_Robotics_101K/motor.cpp.o (symbol from plugin): In function Motor::Motor(unsigned char, unsigned char, unsigned char)': (.text+0x0): multiple definition of Motor::freeRun()’
/tmp/arduino_build_148969/sketch/motor.cpp.o (symbol from plugin):(.text+0x0): first defined here
/tmp/cccF8H5H.ltrans0.ltrans.o: In function setup': /tmp/arduino_modified_sketch_844792/Robot_Complete.ino:125: undefined reference to IRrecv::enableIRIn()’
/tmp/cccF8H5H.ltrans0.ltrans.o: In function loop': /tmp/arduino_modified_sketch_844792/Robot_Complete.ino:196: undefined reference to IRrecv::decode(decode_results*)’
/tmp/arduino_modified_sketch_844792/Robot_Complete.ino:216: undefined reference to IRrecv::resume()' /tmp/cccF8H5H.ltrans0.ltrans.o: In function __static_initialization_and_destruction_0’:
/tmp/arduino_modified_sketch_844792/Robot_Complete.ino:94: undefined reference to `IRrecv::IRrecv(int)’
collect2: error: ld returned 1 exit status
Using library OSEPP_Robotics_101K in folder: /home/pi/Arduino/libraries/OSEPP_Robotics_101K (legacy)
exit status 1
Error compiling for board Arduino Uno.

codes.h (580 Bytes)

irfollower.cpp (2.95 KB)

irfollower.h (1.59 KB)

motor.cpp (2.49 KB)

motor.h (1.45 KB)

Robot_Complete.ino (9.41 KB)

It seems to me that motor and irfollower both have the same issues, so if I get motor figured out, irfollower should be easy to figure out. Here’s the code for each so you don’t need to download…

motor.h

/*

  • Header file for motor driver class
  • created 27 Sep 2013
  • by Blaise Jarrett
  • This example code is in the public domain.

*/

// Include guard
// See: http://en.wikipedia.org/wiki/Include_guard
#ifndef MOTOR_H
#define MOTOR_H

// Include standard ints so we can use specific integer
// types (uint8_t - unsigned 8 bits)
// See: avr-libc: <stdint.h>: Standard Integer Types
#include <stdint.h>

// Declare our motor class
// For info on Object Oriented Programming see:
// http://en.wikipedia.org/wiki/Object-oriented_programming
class Motor {
// Access modifier - Make these members public
// See: http://en.wikipedia.org/wiki/Access_modifiers
public:
// Constructor - Creates our Motor object from 3 pins
Motor(uint8_t pinIN1, uint8_t pinIN2, uint8_t pinEN);
// Drive the motor forward at a defined speed
// Speed is an 8bit unsigned integer. Max 255, Min 0.
void forward(uint8_t speed);
// Drive the motor backwards at a defined speed
// Speed is an 8bit unsigned integer. Max 255, Min 0.
void backward(uint8_t speed);
// Brakes the motor
void brake();
// Lets the motor freely spin
void freeRun();
// Access modifier - Make these members private
private:
// We need instance variables to
// remember the pins for the motor.
uint8_t pinIN1_;
uint8_t pinIN2_;
uint8_t pinEN_;
// The end of our class declaration
};

// The end of our include guard
#endif

motor.cpp

/*

  • Class file for motor driver.
  • In this file we implement the methods
  • we described in the header file.
  • Refer to the Motor Driver Truth Table at the
  • “Understanding the Motor Driver” section.
  • created 27 Sep 2013
  • by Blaise Jarrett
  • This example code is in the public domain.

*/

// Include our class header
#include “motor.h”
// Include the “Arduino” Library
// This is required to give us access to the pinMode,
// digitalWrite, and analogWrite functions
#include <Arduino.h>

// Constructor implementation
// Use the “:” shorthand for initializing class members
// This is called a initialization list
Motor::Motor(uint8_t pinIN1, uint8_t pinIN2, uint8_t pinEN) :
pinIN1_(pinIN1), pinIN2_(pinIN2), pinEN_(pinEN)
{
// set all the pins as outputs
pinMode(pinIN1_, OUTPUT);
pinMode(pinIN2_, OUTPUT);
pinMode(pinEN_, OUTPUT);

// disable the motor
digitalWrite(pinEN_, LOW);
}

// The forward implementation
void Motor::forward(uint8_t speed)
{
// set the control lines to drive the motor forward
// This is described as “Direction B” in the
// “Understanding the Motor Driver” truth table
// (Row# 7)
digitalWrite(pinIN1_, HIGH);
digitalWrite(pinIN2_, LOW);

// use the enable line with PWM to control the speed
analogWrite(pinEN_, speed);
}

// The backward implementation
void Motor::backward(uint8_t speed)
{
// set the control lines to drive the motor backwards
// This is described as “Direction A” in the
// “Understanding the Motor Driver” truth table
// (Row# 6)
digitalWrite(pinIN1_, LOW);
digitalWrite(pinIN2_, HIGH);

// use the enable line with PWM to control the speed
analogWrite(pinEN_, speed);
}

// the brake implementation
void Motor::brake()
{
// set the control lines to brake the motor
// This is described in the
// “Understanding the Motor Driver” truth table
// (Row# 5)
// We could have used either Row# 5 or #8. We
// picked #5 over #8 by random choice.
digitalWrite(pinIN1_, LOW);
digitalWrite(pinIN2_, LOW);
digitalWrite(pinEN_, HIGH);
}

// the free run implementation
void Motor::freeRun()
{
// set the control lines to allow the motor to
// free run. This is described in the
// “Understanding the Motor Driver” truth table.
// Row# 1-4 all result in free runs. Any time the enable
// pin is LOW we get a free run.
// We can just set the enable pin LOW and don’t have to
// worry about the IN1 and IN2 pins.
digitalWrite(pinEN_, LOW);
}