Micro Project_run error

Hii ,
I write some code and I am able to compile it. But when I try to run I got the error in the following image. Can any on help me? I am here also attaching my solution(code) for the problem.

#include "rosbot_control/rosbot_class.h"
#include <ros/ros.h>

#include <string>
#include <iostream>
//#include <math>

using namespace std;

class Escape{
public:
    Escape(string option){ //construct
        Option = option;
    }
    string Option; //Attribute

public:
    RosbotClass rosbot;
    void RoboEsc();

};

void Escape::RoboEsc(){
//Robot is moving till wall is ver near 
    ROS_INFO_STREAM("Robot tries to escape");
    while (rosbot.get_laser(0)<1.5){
        rosbot.move_forward(1);
    }
    ROS_INFO_STREAM(" Robt is goin to take a right turn to avoid colllision");
    
    //ask user for a time to turn
    ROS_INFO_STREAM(" Give a number of seconds to turn, Time: ");
    int time_1;
    cin>>time_1;
    rosbot.turn("clockwise",time_1);

    //ask user for time to move forward
    ROS_INFO_STREAM(" Give a number of seconds to move forward, Time: ");
    int time_2;
    cin>>time_2;
    rosbot.move_forward(time_2);

    //ask user to did the robot reach assumed position
    ROS_INFO_STREAM("Did the robot at correct position: press Y/n");
    string move_1,Y,n;
    cin>>move_1;
    if(move_1 ==Y){
        rosbot.turn("counterclockwise",time_1);
        rosbot.move_forward(5);
    }
    else if(move_1 == n){
        ROS_INFO_STREAM(" Give a number of seconds to move forward, Time: ");
        int time_3;
        cin>>time_3;
        rosbot.move_forward(time_3);
        rosbot.turn("counterclockwise",time_1);
        rosbot.move_forward(5);
    }
    else{
        ROS_INFO_STREAM("yOU GIVEN A WRONG COMMAND PLEASE GIVE THE WRITE COMMAND");
        if(move_1 ==Y){
            rosbot.turn("counterclockwise",time_1);
            rosbot.move_forward(5);
        }
        else if(move_1 == n){
            ROS_INFO_STREAM(" Give a number of seconds to move forward, Time: ");
            int time_3;
            cin>>time_3;
            rosbot.move_forward(time_3);
            rosbot.turn("counterclockwise",time_1);
            rosbot.move_forward(5);
        }
    
    }
    rosbot.turn("clockwise",time_1);


}

int main(){
    Escape("Escape");
    return 0;
}

Look at the first message in red - it has the key to the problem: you did not call ros::init() at all, or not in the right place.

Check the sample code in the course to see how to create it properly.

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