Error while compiling arduino code in SSH.

asked 2016-09-05 14:19:39 -0600

Kishore Kumar gravatar image

updated 2016-09-06 04:10:03 -0600

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

edit retag flag offensive close merge delete

Comments

There isn't enough information here to help you. What is the exact command you using to build?

ahendrix gravatar image ahendrix  ( 2016-09-05 16:04:31 -0600 )edit

I have updated the required details in Edit:1, Please take a look

Kishore Kumar gravatar image Kishore Kumar  ( 2016-09-06 04:10:48 -0600 )edit

I haven't used makefiles to build arduino code before, but a quick google search turned up http://hackaday.com/2015/10/01/arduin... . I can't help any more than that, but perhaps someone else with more experience will see this question and be able to help.

ahendrix gravatar image ahendrix  ( 2016-09-07 12:34:55 -0600 )edit

When you say you have copied ros_lib into the libraries folder in your sketchbook, do you mean you ran the command rosrun rosserial_arduino make_libraries.py ., as indicated in the Arduino IDE Setup Tutorial?

Steven_Daniluk gravatar image Steven_Daniluk  ( 2016-09-09 10:20:07 -0600 )edit