Does not match any class

I am trying to run my code but get some erros , please help.

prototype for 'Motor::Motor(int,int,int,int)' does not any match any in class 'Motor'

Arduino:1.8.15 (Linux), Kart:"Arduino Uno"


motor.cpp:5:1: error: prototype for 'Motor::Motor(int, int, int, int)' does not match any in class 'Motor'
 Motor::Motor(int plus, int minus, int en_a, int en_b) {
 ^~~~~
In file included from /home/ahmet/Masaüstü/navbot/motor.cpp:2:0:
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: error: candidates are: constexpr Motor::Motor(Motor&&)
 class Motor
       ^~~~~
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: error:                 constexpr Motor::Motor(const Motor&)
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:36:9: error:                 Motor::Motor(int, int)
         Motor(int dir, int pwn);
         ^~~~~
motor.cpp:16:29: error: no 'void Motor::rotate(int)' member function declared in class 'Motor'
 void Motor::rotate(int value) {
                             ^
navbot:11:24: error: no matching function for call to 'Motor::Motor(int, int, int, int)'
 Motor right(11,10,20,21);
                        ^
In file included from /home/ahmet/Masaüstü/navbot/navbot.ino:4:0:
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:36:9: note: candidate: Motor::Motor(int, int)
         Motor(int dir, int pwn);
         ^~~~~
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:36:9: note:   candidate expects 2 arguments, 4 provided
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note: candidate: constexpr Motor::Motor(const Motor&)
 class Motor
       ^~~~~
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note:   candidate expects 1 argument, 4 provided
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note: candidate: constexpr Motor::Motor(Motor&&)
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note:   candidate expects 1 argument, 4 provided
navbot:12:21: error: no matching function for call to 'Motor::Motor(int, int, int, int)'
 Motor left(9,8,18,19);
                     ^
In file included from /home/ahmet/Masaüstü/navbot/navbot.ino:4:0:
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:36:9: note: candidate: Motor::Motor(int, int)
         Motor(int dir, int pwn);
         ^~~~~
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:36:9: note:   candidate expects 2 arguments, 4 provided
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note: candidate: constexpr Motor::Motor(const Motor&)
 class Motor
       ^~~~~
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note:   candidate expects 1 argument, 4 provided
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note: candidate: constexpr Motor::Motor(Motor&&)
/home/ahmet/snap/arduino/current/Arduino/libraries/Motor/Motor.h:33:7: note:   candidate expects 1 argument, 4 provided
In file included from /snap/arduino/61/hardware/arduino/avr/cores/arduino/Arduino.h:258:0,
                 from sketch/navbot.ino.cpp:1:
/home/ahmet/Masaüstü/navbot/navbot.ino: In function 'void setup()':
navbot:65:46: error: 'class Motor' has no member named 'en_a'
   attachInterrupt(digitalPinToInterrupt(left.en_a), change_left_a, CHANGE);
                                              ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:37: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                     ^
navbot:65:46: error: 'class Motor' has no member named 'en_a'
   attachInterrupt(digitalPinToInterrupt(left.en_a), change_left_a, CHANGE);
                                              ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:53: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                                     ^
navbot:66:46: error: 'class Motor' has no member named 'en_b'
   attachInterrupt(digitalPinToInterrupt(left.en_b), change_left_b, CHANGE);
                                              ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:37: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                     ^
navbot:66:46: error: 'class Motor' has no member named 'en_b'
   attachInterrupt(digitalPinToInterrupt(left.en_b), change_left_b, CHANGE);
                                              ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:53: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                                     ^
navbot:67:47: error: 'class Motor' has no member named 'en_a'
   attachInterrupt(digitalPinToInterrupt(right.en_a), change_right_a, CHANGE);
                                               ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:37: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                     ^
navbot:67:47: error: 'class Motor' has no member named 'en_a'
   attachInterrupt(digitalPinToInterrupt(right.en_a), change_right_a, CHANGE);
                                               ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:53: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                                     ^
navbot:68:47: error: 'class Motor' has no member named 'en_b'
   attachInterrupt(digitalPinToInterrupt(right.en_b), change_right_b, CHANGE);
                                               ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:37: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                     ^
navbot:68:47: error: 'class Motor' has no member named 'en_b'
   attachInterrupt(digitalPinToInterrupt(right.en_b), change_right_b, CHANGE);
                                               ^
/snap/arduino/61/hardware/arduino/avr/variants/standard/pins_arduino.h:79:53: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
                                                     ^
/home/ahmet/Masaüstü/navbot/navbot.ino: In function 'void loop()':
navbot:117:10: error: 'class Motor' has no member named 'rotate'
     left.rotate(left_output);
          ^~~~~~
navbot:119:11: error: 'class Motor' has no member named 'rotate'
     right.rotate(right_output);
           ^~~~~~
/home/ahmet/Masaüstü/navbot/navbot.ino: In function 'void change_left_a()':
navbot:137:24: error: 'class Motor' has no member named 'en_a'
   if (digitalRead(left.en_a) == HIGH) {
                        ^~~~
navbot:139:26: error: 'class Motor' has no member named 'en_b'
     if (digitalRead(left.en_b) == LOW) {
                          ^~~~
navbot:149:26: error: 'class Motor' has no member named 'en_b'
     if (digitalRead(left.en_b) == HIGH) {
                          ^~~~
/home/ahmet/Masaüstü/navbot/navbot.ino: In function 'void change_left_b()':
navbot:162:24: error: 'class Motor' has no member named 'en_b'
   if (digitalRead(left.en_b) == HIGH) {
                        ^~~~
navbot:164:26: error: 'class Motor' has no member named 'en_a'
     if (digitalRead(left.en_a) == HIGH) {
                          ^~~~
navbot:174:26: error: 'class Motor' has no member named 'en_a'
     if (digitalRead(left.en_a) == LOW) {
                          ^~~~
/home/ahmet/Masaüstü/navbot/navbot.ino: In function 'void change_right_a()':
navbot:190:25: error: 'class Motor' has no member named 'en_a'
   if (digitalRead(right.en_a) == HIGH) {
                         ^~~~
navbot:192:27: error: 'class Motor' has no member named 'en_b'
     if (digitalRead(right.en_b) == LOW) {
                           ^~~~
navbot:202:27: error: 'class Motor' has no member named 'en_b'
     if (digitalRead(right.en_b) == HIGH) {
                           ^~~~
/home/ahmet/Masaüstü/navbot/navbot.ino: In function 'void change_right_b()':
navbot:215:25: error: 'class Motor' has no member named 'en_b'
   if (digitalRead(right.en_b) == HIGH) {
                         ^~~~
navbot:217:27: error: 'class Motor' has no member named 'en_a'
     if (digitalRead(right.en_a) == HIGH) {
                           ^~~~
navbot:227:27: error: 'class Motor' has no member named 'en_a'
     if (digitalRead(right.en_a) == LOW) {
                           ^~~~
exit status 1
prototype for 'Motor::Motor(int, int, int, int)' does not match any in class 'Motor'


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Navbot.ino



//Import Motor - Cytron SPG30E-30K
#include "Motor.h"
#include <ros.h>
#include <geometry_msgs/Twist.h>
#include<PID_v1.h>

ros::NodeHandle  nh;

Motor right(11,10,20,21);
Motor left(9,8,18,19);

volatile long encoder0Pos = 0;    // encoder 1
volatile long encoder1Pos = 0;    // encoder 2

double left_kp = 3.8 , left_ki = 0 , left_kd = 0.03;             // modify for optimal performance
double right_kp = 4 , right_ki = 0 , right_kd = 0.03;

double right_input = 0, right_output = 0, right_setpoint = 0;
PID rightPID(&right_input, &right_output, &right_setpoint, right_kp, right_ki, right_kd, DIRECT);  

double left_input = 0, left_output = 0, left_setpoint = 0;
PID leftPID(&left_input, &left_output, &left_setpoint, left_kp, left_ki, left_kd, DIRECT);  

float demandx=0;
float demandz=0;

double demand_speed_left;
double demand_speed_right;

unsigned long currentMillis;
unsigned long prevMillis;

float encoder0Diff;
float encoder1Diff;

float encoder0Error;
float encoder1Error;

float encoder0Prev;
float encoder1Prev;

void cmd_vel_cb( const geometry_msgs::Twist& twist){
  demandx = twist.linear.x;
  demandz = twist.angular.z;
}

ros::Subscriber<geometry_msgs::Twist> sub("cmd_vel", cmd_vel_cb );

void setup() {
  nh.initNode();
  nh.subscribe(sub);
//  Serial.begin(115200);

  rightPID.SetMode(AUTOMATIC);
  rightPID.SetSampleTime(1);
  rightPID.SetOutputLimits(-100, 100);

  leftPID.SetMode(AUTOMATIC);
  leftPID.SetSampleTime(1);
  leftPID.SetOutputLimits(-100, 100);

//  Serial.println("Basic Encoder Test:");
  attachInterrupt(digitalPinToInterrupt(left.en_a), change_left_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(left.en_b), change_left_b, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_a), change_right_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_b), change_right_b, CHANGE);
}

void loop() {
  currentMillis = millis();
  if (currentMillis - prevMillis >= 10){
    prevMillis = currentMillis;
//    if(Serial.available()>0){
//      char c = Serial.read();
//      if(c == 'a'){
//        demandx = 0.5;
//        demandz=0;
//      }else if (c == 'b'){
//        demandx = -0.5;
//        demandz = 0;
//      }else if(c == 'c'){
//        demandx = 0;
//        demandz = 1;
//      }else if(c == 'd'){
//        demandx = 0;
//        demandz = 1;
//      }else if(c == 'e'){
//        demandx = 0;
//        demandz = 0;
//      }
//    }
    demand_speed_left = demandx - (demandz*0.1075);
    demand_speed_right = demandx + (demandz*0.1075);

    /*PID controller for speed control
      Base speed being 1 ms and the demand_speed variables controlling it at fractions of the base.
      The PID controller keeps trying to match the difference 
      in encoder counts to match with the required amount, hence controlling the speed. */
    encoder0Diff = encoder0Pos - encoder0Prev; // Get difference between ticks to compute speed
    encoder1Diff = encoder1Pos - encoder1Prev;

    encoder0Error = (demand_speed_left*39.65)-encoder0Diff; // 3965 ticks in 1m = 39.65 ticks in 10ms, due to the 10 millis loop
    encoder1Error = (demand_speed_right*39.65)-encoder1Diff;

    encoder0Prev = encoder0Pos; // Saving values
    encoder1Prev = encoder1Pos;

    left_setpoint = demand_speed_left*39.65;  //Setting required speed as a mul/frac of 1 m/s
    right_setpoint = demand_speed_right*39.65;

    left_input = encoder0Diff;  //Input to PID controller is the current difference
    right_input = encoder1Diff;

    leftPID.Compute();
    left.rotate(left_output);
    rightPID.Compute();
    right.rotate(right_output);
//    Serial.print(encoder0Pos);
//    Serial.print(",");
//    Serial.println(encoder1Pos);
  }

}



// ************** encoders interrupts **************

// ************** encoder 1 *********************


void change_left_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(left.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(left.en_b) == LOW) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_b) == HIGH) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }

}

void change_left_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(left.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(left.en_a) == HIGH) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_a) == LOW) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }


}

// ************** encoder 2 *********************

void change_right_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(right.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(right.en_b) == LOW) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_b) == HIGH) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }

}

void change_right_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(right.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(right.en_a) == HIGH) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_a) == LOW) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }


}

Motor.cpp

#include "Arduino.h"
#include "Motor.h"


Motor::Motor(int plus, int minus, int en_a, int en_b) {
  pinMode(plus,OUTPUT);
  pinMode(minus,OUTPUT);
  pinMode(en_a,INPUT_PULLUP);
  pinMode(en_b,INPUT_PULLUP);
  Motor::plus = plus;
  Motor::minus = minus;
  Motor::en_a = en_a;
  Motor::en_b = en_b;
}

void Motor::rotate(int value) {
  if(value>=0){
    //Max Voltage with 16V battery with 12V required
    //(12/16)*255 ~=190
//    Serial.println("called");
//    Serial.println(plus);
    int out = map(value, 0, 100, 0, 190);
    analogWrite(plus,out);
    analogWrite(minus,0);
  }else{
    //Max Voltage with 16V battery with 12V required
    //(12/16)*255 ~=190
    int out = map(value, 0, -100, 0, 190);
    analogWrite(plus,0);
    analogWrite(minus,out);
  }
}

Motor.h

/*
  Motor.h - Library for working with the Cytron SPG30E-30K.
  Created by Vinay Lanka, January 27, 2021.
*/
#ifndef Motor_h
#define Motor_h

#include "Arduino.h"

class Motor {
  public:
    //Constructor - Plus and Minus are the Motor output / en_a and en_b are the encoder inputs
    Motor(int plus, int minus, int en_a, int en_b);
    //Spin the motor with a percentage value
    void rotate(int value);
    //Motor Outputs - plus is one direction and minus is the other
    int plus;
    int minus;
    //Encoder Inputs
    int en_a;
    int en_b;
};

#endif

Welcome to the forum

Your topic was MOVED to its current forum category as it is more suitable than the original as it is not an Introductory Tutorial

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

It looks like you are trying to use a library that is for DC brushed motors for a stepper motor. Use a library that is written for steppers like the Stepper library, AccelStepper library or MobaTools stepper library. All are either included with the IDE or via the IDE library manager.

If I found the right Motor library, the constructor takes only 2 arguments, the pin number for direction control and the pin number for PWM. You included 4 arguments, thus the error.

Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

i entered errors message and regulate my question

What motors and motor drivers are you using

Where did you find that Motor library.

i entered errors message and regulate my question

i use pololu motors and L298n motor drivers https://www.pololu.com/product/2826

Your sketch compiled without errors or warnings after I removed the RobotOperatingSystem libraries and code. I think that might mean that 'ros.h' is defining a "Motor" object that somehow conflicts with yours.

//Import Motor - Cytron SPG30E-30K
#include "Motor.h"
// #include <ros.h>
// #include <geometry_msgs/Twist.h>
#include<PID_v1.h>

// ros::NodeHandle  nh;

Motor right(11, 10, 20, 21);
Motor left(9, 8, 18, 19);

volatile long encoder0Pos = 0;    // encoder 1
volatile long encoder1Pos = 0;    // encoder 2

double left_kp = 3.8 , left_ki = 0 , left_kd = 0.03;             // modify for optimal performance
double right_kp = 4 , right_ki = 0 , right_kd = 0.03;

double right_input = 0, right_output = 0, right_setpoint = 0;
PID rightPID(&right_input, &right_output, &right_setpoint, right_kp, right_ki, right_kd, DIRECT);

double left_input = 0, left_output = 0, left_setpoint = 0;
PID leftPID(&left_input, &left_output, &left_setpoint, left_kp, left_ki, left_kd, DIRECT);

float demandx = 0;
float demandz = 0;

double demand_speed_left;
double demand_speed_right;

unsigned long currentMillis;
unsigned long prevMillis;

float encoder0Diff;
float encoder1Diff;

float encoder0Error;
float encoder1Error;

float encoder0Prev;
float encoder1Prev;

void setup()
{
  //  Serial.begin(115200);

  rightPID.SetMode(AUTOMATIC);
  rightPID.SetSampleTime(1);
  rightPID.SetOutputLimits(-100, 100);

  leftPID.SetMode(AUTOMATIC);
  leftPID.SetSampleTime(1);
  leftPID.SetOutputLimits(-100, 100);

}

void loop()
{
  currentMillis = millis();
  if (currentMillis - prevMillis >= 10)
  {
    prevMillis = currentMillis;
    //    if(Serial.available()>0){
    //      char c = Serial.read();
    //      if(c == 'a'){
    //        demandx = 0.5;
    //        demandz=0;
    //      }else if (c == 'b'){
    //        demandx = -0.5;
    //        demandz = 0;
    //      }else if(c == 'c'){
    //        demandx = 0;
    //        demandz = 1;
    //      }else if(c == 'd'){
    //        demandx = 0;
    //        demandz = 1;
    //      }else if(c == 'e'){
    //        demandx = 0;
    //        demandz = 0;
    //      }
    //    }
    demand_speed_left = demandx - (demandz * 0.1075);
    demand_speed_right = demandx + (demandz * 0.1075);

    /*PID controller for speed control
      Base speed being 1 ms and the demand_speed variables controlling it at fractions of the base.
      The PID controller keeps trying to match the difference
      in encoder counts to match with the required amount, hence controlling the speed. */
    encoder0Diff = encoder0Pos - encoder0Prev; // Get difference between ticks to compute speed
    encoder1Diff = encoder1Pos - encoder1Prev;

    encoder0Error = (demand_speed_left * 39.65) - encoder0Diff; // 3965 ticks in 1m = 39.65 ticks in 10ms, due to the 10 millis loop
    encoder1Error = (demand_speed_right * 39.65) - encoder1Diff;

    encoder0Prev = encoder0Pos; // Saving values
    encoder1Prev = encoder1Pos;

    left_setpoint = demand_speed_left * 39.65; //Setting required speed as a mul/frac of 1 m/s
    right_setpoint = demand_speed_right * 39.65;

    left_input = encoder0Diff;  //Input to PID controller is the current difference
    right_input = encoder1Diff;

    leftPID.Compute();
    left.rotate(left_output);
    rightPID.Compute();
    right.rotate(right_output);
    //    Serial.print(encoder0Pos);
    //    Serial.print(",");
    //    Serial.println(encoder1Pos);
  }

}

what do i need to do to run it correctly?

It looks like your sketch is getting motor.cpp (not Motor.cpp) from your sketch folder but motor.cpp is getting Motor.h from the installed Motor library, not the sketch folder. It looks like the motor.cpp in your sketch folder is not compatible with the Motor.h in the installed Motor library. Is there a Motor.h in your sketch folder?

@ahmett1

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Other general help and troubleshooting advice can be found here.

Thank you.

I deleted references to ros, PID_v1 etc in motor.ino and it compiles and link OK on my PC
no modification to motor.cpp or motor.h
this is the code which compiles OK

//Import Motor - Cytron SPG30E-30K
#include "Motor.h"
//#include <ros.h>
//#include <geometry_msgs/Twist.h>
//#include<PID_v1.h>

//ros::NodeHandle  nh;

Motor right(11,10,20,21);
Motor left(9,8,18,19);

volatile long encoder0Pos = 0;    // encoder 1
volatile long encoder1Pos = 0;    // encoder 2

double left_kp = 3.8 , left_ki = 0 , left_kd = 0.03;             // modify for optimal performance
double right_kp = 4 , right_ki = 0 , right_kd = 0.03;

double right_input = 0, right_output = 0, right_setpoint = 0;
//PID rightPID(&right_input, &right_output, &right_setpoint, right_kp, right_ki, right_kd, DIRECT);  

double left_input = 0, left_output = 0, left_setpoint = 0;
//PID leftPID(&left_input, &left_output, &left_setpoint, left_kp, left_ki, left_kd, DIRECT);  

float demandx=0;
float demandz=0;

double demand_speed_left;
double demand_speed_right;

unsigned long currentMillis;
unsigned long prevMillis;

float encoder0Diff;
float encoder1Diff;

float encoder0Error;
float encoder1Error;

float encoder0Prev;
float encoder1Prev;

/*void cmd_vel_cb( const geometry_msgs::Twist& twist){
  demandx = twist.linear.x;
  demandz = twist.angular.z;
}

ros::Subscriber<geometry_msgs::Twist> sub("cmd_vel", cmd_vel_cb );
*/
void setup() {
//  nh.initNode();
 // nh.subscribe(sub);
//  Serial.begin(115200);

//  rightPID.SetMode(AUTOMATIC);
//  rightPID.SetSampleTime(1);
 // rightPID.SetOutputLimits(-100, 100);

//  leftPID.SetMode(AUTOMATIC);
//  leftPID.SetSampleTime(1);
//  leftPID.SetOutputLimits(-100, 100);

//  Serial.println("Basic Encoder Test:");
  attachInterrupt(digitalPinToInterrupt(left.en_a), change_left_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(left.en_b), change_left_b, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_a), change_right_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_b), change_right_b, CHANGE);
}

void loop() {
  currentMillis = millis();
  if (currentMillis - prevMillis >= 10){
    prevMillis = currentMillis;
//    if(Serial.available()>0){
//      char c = Serial.read();
//      if(c == 'a'){
//        demandx = 0.5;
//        demandz=0;
//      }else if (c == 'b'){
//        demandx = -0.5;
//        demandz = 0;
//      }else if(c == 'c'){
//        demandx = 0;
//        demandz = 1;
//      }else if(c == 'd'){
//        demandx = 0;
//        demandz = 1;
//      }else if(c == 'e'){
//        demandx = 0;
//        demandz = 0;
//      }
//    }
    demand_speed_left = demandx - (demandz*0.1075);
    demand_speed_right = demandx + (demandz*0.1075);

    /*PID controller for speed control
      Base speed being 1 ms and the demand_speed variables controlling it at fractions of the base.
      The PID controller keeps trying to match the difference 
      in encoder counts to match with the required amount, hence controlling the speed. */
    encoder0Diff = encoder0Pos - encoder0Prev; // Get difference between ticks to compute speed
    encoder1Diff = encoder1Pos - encoder1Prev;

    encoder0Error = (demand_speed_left*39.65)-encoder0Diff; // 3965 ticks in 1m = 39.65 ticks in 10ms, due to the 10 millis loop
    encoder1Error = (demand_speed_right*39.65)-encoder1Diff;

    encoder0Prev = encoder0Pos; // Saving values
    encoder1Prev = encoder1Pos;

    left_setpoint = demand_speed_left*39.65;  //Setting required speed as a mul/frac of 1 m/s
    right_setpoint = demand_speed_right*39.65;

    left_input = encoder0Diff;  //Input to PID controller is the current difference
    right_input = encoder1Diff;

 //   leftPID.Compute();
//    left.rotate(left_output);
// //   rightPID.Compute();
    right.rotate(right_output);
//    Serial.print(encoder0Pos);
//    Serial.print(",");
//    Serial.println(encoder1Pos);
  }

}



// ************** encoders interrupts **************

// ************** encoder 1 *********************


void change_left_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(left.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(left.en_b) == LOW) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_b) == HIGH) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }

}

void change_left_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(left.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(left.en_a) == HIGH) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_a) == LOW) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }


}

// ************** encoder 2 *********************

void change_right_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(right.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(right.en_b) == LOW) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_b) == HIGH) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }

}

void change_right_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(right.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(right.en_a) == HIGH) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_a) == LOW) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }


}

I have encountered such a problem at the moment related to this problem of making edits in the library,what should i do?

//AGV Machine - Vinay Lanka

//Import Motor - Cytron SPG30E-30K
#include "Motor.h"
#include <ros.h>
#include <geometry_msgs/Twist.h>
#include <std_msgs/Int16.h>
#include<PID_v1.h>
#include <geometry_msgs/Vector3Stamped.h>
#include <ros/time.h>


ros::NodeHandle  nh;

#define LOOPTIME 10

Motor right(11,10,20,21);
Motor left(9,8,18,19);

volatile long encoder0Pos = 0;    // encoder 1
volatile long encoder1Pos = 0;    // encoder 2

double left_kp = 3.8 , left_ki = 0 , left_kd = 0.0;             // modify for optimal performance
double right_kp = 4 , right_ki = 0 , right_kd = 0.0;

float demandx=0;
float demandz=0;

double demand_speed_left;
double demand_speed_right;

double right_input = 0, right_output = 0, right_setpoint = 0;
PID rightPID(&right_input, &right_output, &right_setpoint, right_kp, right_ki, right_kd, DIRECT);  

double left_input = 0, left_output = 0, left_setpoint = 0;
PID leftPID(&left_input, &left_output, &left_setpoint, left_kp, left_ki, left_kd, DIRECT);  



unsigned long currentMillis;
unsigned long prevMillis;

float encoder0Diff;
float encoder1Diff;

float encoder0Error;
float encoder1Error;

float encoder0Prev;
float encoder1Prev;

void cmd_vel_cb( const geometry_msgs::Twist& twist){
  demandx = twist.linear.x;
  demandz = twist.angular.z;
}

ros::Subscriber<geometry_msgs::Twist> sub("cmd_vel", cmd_vel_cb );
std_msgs::Int16 left_wheel_msg;
ros::Publisher left_wheel_pub("lwheel" , &left_wheel_msg);
std_msgs::Int16 right_wheel_msg;
ros::Publisher right_wheel_pub("rwheel" , &right_wheel_msg);

geometry_msgs::Vector3Stamped speed_msg;                                //create a "speed_msg" ROS message
ros::Publisher speed_pub("speed", &speed_msg);                          //create a publisher to ROS topic "speed" using the "speed_msg" type

double speed_act_left = 0;                    //Actual speed for left wheel in m/s
double speed_act_right = 0;                    //Command speed for left wheel in m/s 

void setup() {
  nh.initNode();
  nh.subscribe(sub);
  nh.advertise(left_wheel_pub); 
  nh.advertise(right_wheel_pub);    //prepare to publish speed in ROS topic
//  Serial.begin(115200);
  
  rightPID.SetMode(AUTOMATIC);
  rightPID.SetSampleTime(1);
  rightPID.SetOutputLimits(-100, 100);

  leftPID.SetMode(AUTOMATIC);
  leftPID.SetSampleTime(1);
  leftPID.SetOutputLimits(-100, 100);
  
//  Serial.println("Basic Encoder Test:");
  attachInterrupt(digitalPinToInterrupt(left.en_a), change_left_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(left.en_b), change_left_b, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_a), change_right_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_b), change_right_b, CHANGE);
}

void loop() {
  currentMillis = millis();
  if (currentMillis - prevMillis >= LOOPTIME){
    prevMillis = currentMillis;

    demand_speed_left = demandx - (demandz*0.1075);
    demand_speed_right = demandx + (demandz*0.1075);
  
    /*PID controller for speed control
      Base speed being 1 ms and the demand_speed variables controlling it at fractions of the base.
      The PID controller keeps trying to match the difference 
      in encoder counts to match with the required amount, hence controlling the speed. */
    encoder0Diff = encoder0Pos - encoder0Prev; // Get difference between ticks to compute speed
    encoder1Diff = encoder1Pos - encoder1Prev;
    
    speed_act_left = encoder0Diff;                    
    speed_act_right = encoder1Diff; 
  
    encoder0Error = (demand_speed_left*39.65)-encoder0Diff; // 3965 ticks in 1m = 39.65 ticks in 10ms, due to the 10 millis loop
    encoder1Error = (demand_speed_right*39.65)-encoder1Diff;
  
    encoder0Prev = encoder0Pos; // Saving values
    encoder1Prev = encoder1Pos;
  
    left_setpoint = demand_speed_left*39.65;  //Setting required speed as a mul/frac of 1 m/s
    right_setpoint = demand_speed_right*39.65;
  
    left_input = encoder0Diff;  //Input to PID controller is the current difference
    right_input = encoder1Diff;
    
    leftPID.Compute();
    left.rotate(left_output);
    rightPID.Compute();
    right.rotate(right_output);
//    Serial.print(encoder0Pos);
//    Serial.print(",");
//    Serial.println(encoder1Pos);
  
  publishSpeed(LOOPTIME);
  if(updatenh>10){
    nh.spinOnce();
    updatenh=0;
  }else{
    updatenh++;
  }  
  }
    
   
}


//Publish function for odometry, uses a vector type message to send the data (message type is not meant for that but that's easier than creating a specific message type)
void publishSpeed(double time) {
  speed_msg.header.stamp = nh.now();      //timestamp for odometry data
  speed_msg.vector.x = speed_act_left;    //left wheel speed (in m/s)
  speed_msg.vector.y = speed_act_right;   //right wheel speed (in m/s)
  speed_msg.vector.z = time/1000;         //looptime, should be the same as specified in LOOPTIME (in s)
  speed_pub.publish(&speed_msg);
//  nh.loginfo("Publishing odometry");
}


// ************** encoders interrupts **************

// ************** encoder 1 *********************


void change_left_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(left.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(left.en_b) == LOW) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_b) == HIGH) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }
 
}

void change_left_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(left.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(left.en_a) == HIGH) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_a) == LOW) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }
  

}

// ************** encoder 2 *********************

void change_right_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(right.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(right.en_b) == LOW) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_b) == HIGH) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }
 
}

void change_right_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(right.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(right.en_a) == HIGH) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_a) == LOW) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }
  

}

error message

Arduino:1.8.19 (Linux), Kart:"Arduino Uno"











/home/petka/Masaüstü/navbot/navbot.ino: In function 'void loop()':
navbot:130:6: error: 'updatenh' was not declared in this scope
   if(updatenh>10){
      ^~~~~~~~
exit status 1
'updatenh' was not declared in this scope


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

you don't appear to have defined updatenh in the code, e.g.

  int updatenh;

i have another problem what shoul i do?

//AGV Machine - Vinay Lanka

//Import Motor - Cytron SPG30E-30K
#include "Motor.h"
#include <ros.h>
#include <geometry_msgs/Twist.h>
#include <std_msgs/Int16.h>
#include<PID_v1.h>

#include <ros/time.h>


ros::NodeHandle  nh;

#define LOOPTIME 10

Motor right(11,10,20,21);
Motor left(9,8,18,19);

volatile long encoder0Pos = 0;    // encoder 1
volatile long encoder1Pos = 0;    // encoder 2

double left_kp = 3.8 , left_ki = 0 , left_kd = 0.0;             // modify for optimal performance
double right_kp = 4 , right_ki = 0 , right_kd = 0.0;

float demandx=0;
float demandz=0;

double demand_speed_left;
double demand_speed_right;

double right_input = 0, right_output = 0, right_setpoint = 0;
PID rightPID(&right_input, &right_output, &right_setpoint, right_kp, right_ki, right_kd, DIRECT);  

double left_input = 0, left_output = 0, left_setpoint = 0;
PID leftPID(&left_input, &left_output, &left_setpoint, left_kp, left_ki, left_kd, DIRECT);  



unsigned long currentMillis;
unsigned long prevMillis;

float encoder0Diff;
float encoder1Diff;

float encoder0Error;
float encoder1Error;

float encoder0Prev;
float encoder1Prev;

void cmd_vel_cb( const geometry_msgs::Twist& twist){
  demandx = twist.linear.x;
  demandz = twist.angular.z;
}

ros::Subscriber<geometry_msgs::Twist> sub("cmd_vel", cmd_vel_cb );
std_msgs::Int16 left_wheel_msg;
ros::Publisher left_wheel_pub("lwheel" , &left_wheel_msg);
std_msgs::Int16 right_wheel_msg;
ros::Publisher right_wheel_pub("rwheel" , &right_wheel_msg);


double speed_act_left = 0;                    //Actual speed for left wheel in m/s
double speed_act_right = 0;                    //Command speed for left wheel in m/s 

void setup() {
  nh.initNode();
  nh.subscribe(sub);
  nh.advertise(left_wheel_pub); 
  nh.advertise(right_wheel_pub);    //prepare to publish speed in ROS topic
//  Serial.begin(115200);
  
  rightPID.SetMode(AUTOMATIC);
  rightPID.SetSampleTime(1);
  rightPID.SetOutputLimits(-100, 100);

  leftPID.SetMode(AUTOMATIC);
  leftPID.SetSampleTime(1);
  leftPID.SetOutputLimits(-100, 100);
  
//  Serial.println("Basic Encoder Test:");
  attachInterrupt(digitalPinToInterrupt(left.en_a), change_left_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(left.en_b), change_left_b, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_a), change_right_a, CHANGE);
  attachInterrupt(digitalPinToInterrupt(right.en_b), change_right_b, CHANGE);
}

void loop() {
  currentMillis = millis();
  if (currentMillis - prevMillis >= LOOPTIME){
    prevMillis = currentMillis;

    demand_speed_left = demandx - (demandz*0.1075);
    demand_speed_right = demandx + (demandz*0.1075);
  
    /*PID controller for speed control
      Base speed being 1 ms and the demand_speed variables controlling it at fractions of the base.
      The PID controller keeps trying to match the difference 
      in encoder counts to match with the required amount, hence controlling the speed. */
    encoder0Diff = encoder0Pos - encoder0Prev; // Get difference between ticks to compute speed
    encoder1Diff = encoder1Pos - encoder1Prev;
    
    speed_act_left = encoder0Diff;                    
    speed_act_right = encoder1Diff; 
  
    encoder0Error = (demand_speed_left*39.65)-encoder0Diff; // 3965 ticks in 1m = 39.65 ticks in 10ms, due to the 10 millis loop
    encoder1Error = (demand_speed_right*39.65)-encoder1Diff;
  
    encoder0Prev = encoder0Pos; // Saving values
    encoder1Prev = encoder1Pos;
  
    left_setpoint = demand_speed_left*39.65;  //Setting required speed as a mul/frac of 1 m/s
    right_setpoint = demand_speed_right*39.65;
  
    left_input = encoder0Diff;  //Input to PID controller is the current difference
    right_input = encoder1Diff;
    
    leftPID.Compute();
    left.rotate(left_output);
    rightPID.Compute();
    right.rotate(right_output);
//    Serial.print(encoder0Pos);
//    Serial.print(",");
//    Serial.println(encoder1Pos);
  int updatenh;
  publishPos(LOOPTIME);
  
  if(updatenh>10){
    nh.spinOnce();
    updatenh=0;
  }else{
    updatenh++;
  }  
  }
    
   
}


//Publish function for odometry, uses a vector type message to send the data (message type is not meant for that but that's easier than creating a specific message type)
void publishPos(double time) {
  
  left_wheel_msg.data = pos_act_left;      //timestamp for odometry data
  right_wheel_msg.data = pos_act_right;    //left wheel speed (in m/s)
  left_wheel_pub.publish(&left_wheel_msg);   //right wheel speed (in m/s)
  right_wheel_pub.publish(&right_wheel_msg);         //looptime, should be the same as specified in LOOPTIME (in s)

//  nh.loginfo("Publishing odometry");
}


// ************** encoders interrupts **************

// ************** encoder 1 *********************


void change_left_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(left.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(left.en_b) == LOW) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_b) == HIGH) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }
 
}

void change_left_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(left.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(left.en_a) == HIGH) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(left.en_a) == LOW) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }
  

}

// ************** encoder 2 *********************

void change_right_a(){  

  // look for a low-to-high on channel A
  if (digitalRead(right.en_a) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(right.en_b) == LOW) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_b) == HIGH) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }
 
}

void change_right_b(){  

  // look for a low-to-high on channel B
  if (digitalRead(right.en_b) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(right.en_a) == HIGH) {  
      encoder1Pos = encoder1Pos - 1;         // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(right.en_a) == LOW) {   
      encoder1Pos = encoder1Pos - 1;          // CW
    } 
    else {
      encoder1Pos = encoder1Pos + 1;          // CCW
    }
  }
  

}
Arduino:1.8.19 (Linux), Kart:"Arduino Uno"








/home/petka/Masaüstü/navbot2/navbot2.ino: In function 'void publishPos(double)':
navbot2:144:25: error: 'pos_act_left' was not declared in this scope
   left_wheel_msg.data = pos_act_left;      //timestamp for odometry data
                         ^~~~~~~~~~~~
/home/petka/Masaüstü/navbot2/navbot2.ino:144:25: note: suggested alternative: 'speed_act_left'
   left_wheel_msg.data = pos_act_left;      //timestamp for odometry data
                         ^~~~~~~~~~~~
                         speed_act_left
navbot2:145:26: error: 'pos_act_right' was not declared in this scope
   right_wheel_msg.data = pos_act_right;    //left wheel speed (in m/s)
                          ^~~~~~~~~~~~~
/home/petka/Masaüstü/navbot2/navbot2.ino:145:26: note: suggested alternative: 'speed_act_right'
   right_wheel_msg.data = pos_act_right;    //left wheel speed (in m/s)
                          ^~~~~~~~~~~~~
                          speed_act_right
exit status 1
'pos_act_left' was not declared in this scope


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Maybe declare the missing variables such as pos_act_left and pos_act_right

where exactly should i declare

If you declare them at the start of the sketch then their scope will be global and they will be available throughout the sketch.

That may not be technically the best place to declare them, but I suspect that you are more interested in getting the sketch working than a discussion on the rights and wrongs of global scope compared to local scope

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.