src/nodes/src/movement.cpp
// Waits for the Movement node to return a message
Waits for the Movement node to return a message
Waits for the Movement node to return a message
void Movement::callback(const std_msgs::String::ConstPtr& message) {
        std::string data = message->data.c_str();
        ros::AsyncSpinner spinner = ros::AsyncSpinner(1);
        spinner.start();
        int x_pos = std::stoi(data.substr(0, data.find(" ")));
        int y_pos = std::stoi(data.substr(data.find(" "), data.length()-data.find(" ")));
        if(x_pos < 0 && x_pos > 500) {
            spinner.stop();
            publishData("The x position exceeds the defined workspace!");
        } else if(y_pos < 0 && y_pos > 500) {
            spinner.stop();
            publishData("The y position exceeds the defined workspace!");
        }
        arranger->arrange(x_pos / 1000.0, y_pos / 1000.0);
        spinner.stop();
        publishData("");
    }
void Movement :: callback ( const std_msgs :: String :: ConstPtr & message ) { std :: string data = message -> data . c_str ( ) ; ros :: AsyncSpinner spinner = ros :: AsyncSpinner ( 1 ) ; spinner . start ( ) ; int x_pos = std :: stoi ( data . substr ( 0 , data . find ( " " ) ) ) ; int y_pos = std :: stoi ( data . substr ( data . find ( " " ) , data . length ( ) - data . find ( " " ) ) ) ; if ( x_pos < 0 && x_pos > 500 ) { spinner . stop ( ) ; publishData ( " " ) ; } else if ( y_pos < 0 && y_pos > 500 ) { spinner . stop ( ) ; publishData ( " " ) ; } arranger -> arrange ( x_pos / 1000.0 , y_pos / 1000.0 ) ; spinner . stop ( ) ; publishData ( " " ) ; }
Waits for the Movement node to return a message
Waits for the Movement node to return a message
// Continuous spinning to operate robot // Extract position values (in mm) // Error checking // Pick up letter and arrange // Stop spinner and publish success