Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error while compiling arduino code in SSH.

I am using raspberry pi with ubuntu installed in it. An Arduino is being used to interface sensors and motors. I have SSHed the raspberry pi and tried to compile an ROS library(ros.h) dependent Arduino code in terminal (IDE is not used) and ended up in the following error

 /usr/share/arduino/hardware/tools/avr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=105 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard   -Wall -ffunction-sections -fdata-sections -Os -fno-exceptions   teleop.ino -o build-uno/teleop.o
teleop.ino:1:17: fatal error: ros.h: No such file or directory
 #include <ros.h>
                 ^
compilation terminated.
make: *** [build-uno/teleop.o] Error 1

Error while compiling arduino code in SSH.

I am using raspberry pi with ubuntu installed in it. An Arduino is being used to interface sensors and motors. I have SSHed the raspberry pi and tried to compile an ROS library(ros.h) dependent Arduino code in terminal (IDE is not used) and ended up in the following error

Command used : make

 /usr/share/arduino/hardware/tools/avr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=105 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard   -Wall -ffunction-sections -fdata-sections -Os -fno-exceptions   teleop.ino -o build-uno/teleop.o
teleop.ino:1:17: fatal error: ros.h: No such file or directory
 #include <ros.h>
                 ^
compilation terminated.
make: *** [build-uno/teleop.o] Error 1

Error while compiling arduino code in SSH.

I am using raspberry pi with ubuntu installed in it. An Arduino is being used to interface sensors and motors. I have SSHed the raspberry pi and tried to compile an ROS library(ros.h) dependent Arduino code in terminal (IDE is not used) and ended up in the following error

Command used : make

 /usr/share/arduino/hardware/tools/avr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=105 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard   -Wall -ffunction-sections -fdata-sections -Os -fno-exceptions   teleop.ino -o build-uno/teleop.o
teleop.ino:1:17: fatal error: ros.h: No such file or directory
 #include <ros.h>
                 ^
compilation terminated.
make: *** [build-uno/teleop.o] Error 1

Edit 1: I have followed the below steps to create and build the Arduino cod ein SSH. I am aware that the dependent file ros_lib is not available in the directory so the error is popping up. How to resolve it?

Note:

  1. I copied ros_lib folder to the libraries folder in mysketchbook folder but it didn't help.

  2. The code is successfully compiling and uploading in in Arduino IDE

$:mkdir ~/mysketchbook

$:cd ~/mysketchbook

$:ln -s /usr/share/arduino/Arduino.mk

$:mkdir teleop

$:cd teleop

$:sudo nano teleop.ino

My arduino code is as follows

   #include <ros.h>
    #include <std_msgs/UInt16.h>
    #include <geometry_msgs/Twist.h>
    ///Left Motor  Pins
    #define INA_1 7
    #define INB_1 12
    #define PWM_1 5

    ///Right Motor Pins
    #define INA_2 11
    #define INB_2 10
    #define PWM_2 6
    void printCurrentSensing(void);

    float angInput;
    float velInput;

    void setup()
    {

    //Setting Left Motor pin as OUTPUT
    pinMode(INA_1,OUTPUT); 
    pinMode(INB_1,OUTPUT);

    //Setting Right Motor pin as OUTPUT
    pinMode(INA_2,OUTPUT);
    pinMode(INB_2,OUTPUT);
    }
    ros::NodeHandle nh;

    void chatterCallback ( const geometry_msgs::Twist &msg) {
        velInput = msg.linear.x;
        angInput = msg.angular.z;
    }

    void loop(){


    //SETTING THE LIMITS ON THE SPEED
        if(velInput>0){      
         digitalWrite(INA_1,HIGH);
         digitalWrite(INB_1,LOW);
         analogWrite(PWM_1,100);

    //Right Motor 
        digitalWrite(INA_2,LOW);
        digitalWrite(INB_2,HIGH);
        analogWrite(PWM_2,100); 
        }      
        if(velInput<0){      

         digitalWrite(INA_1,LOW);
         digitalWrite(INB_1,HIGH);
         analogWrite(PWM_1,100);

    //Right Motor 
        digitalWrite(INA_2,HIGH);
        digitalWrite(INB_2,LOW);
        analogWrite(PWM_2,100); 
        }      
        if(angInput>0){     
          digitalWrite(INA_1,HIGH);
         digitalWrite(INB_1,LOW);
         analogWrite(PWM_1,100);

    //Right Motor 
        digitalWrite(INA_2,HIGH);
        digitalWrite(INB_2,HIGH);
        analogWrite(PWM_2,100);        
        }      
        if(angInput<0){      
           digitalWrite(INA_1,HIGH);
         digitalWrite(INB_1,HIGH);
         analogWrite(PWM_1,100);

    //Right Motor 
        digitalWrite(INA_2,LOW);
        digitalWrite(INB_2,HIGH);
        analogWrite(PWM_2,100);      
        }

    }

$:sudo nano Makefile

My make file code is as follows

BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyACM0
ARDUINO_LIBS =
ARDUINO_DIR = /usr/share/arduino
include ../Arduino.mk

$: make