ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I see one possibility. Note you do not tell the robot to go 0.3m. You tell it go some velocity and then tell it to stop at some point in time after it has passed 0.3m. It's likely the code works as you expect. It passes 0.3m and then comes to a stop some distance later.

The question is how long after it has passed 0.3m does the condition

if ( line_travel < triagle_line1 )

get checked? It if gets checked when robot is at 0.4m and takes a 0.1m to stop, then it's working great.

If you provide the data that you print to the screen, but include the commanded velocity at each 'cout' statement, we'd have more to go on. You should change code so you can watch the robot come to stop prior to turning

More like this:

   if ( line_travel < triagle_line1 )  
        { 
            counter = 0; // init the counter
            controlVel_.angular.z = 0.0;
            controlVel_.linear.x  = vel_line_;
            controlVel_.linear.y  = 0;
            controlVel_.linear.z  = 0;  
            Is_Fininsh_ = false;  
            #ifdef VERBOSE
             cout<<"In IF statement: "<< curr_pos_.x <<"||"<< start_pos_.x<<"||  ||"<<curr_pos_.y<<"||"<<start_pos_.y<<"||  ||"<< line_travel <<"||  ||"<< line_travel << controlVel_.linear.x <<endl;
            #endif
        }  
        else  
        {   
            controlVel_.angular.z = 0.0;
            controlVel_.linear.x  = 0.0;
            controlVel_.linear.y  = 0;  
            controlVel_.linear.z  = 0;  
            state_ = 1;
            cout<<"In ELSE statement: "<< counter << "||"<< curr_pos_.x <<"||"<< start_pos_.x<<"||  ||"<<curr_pos_.y<<"||"<<start_pos_.y<<"||  ||"<< line_travel <<"||  ||"<< line_travel << controlVel_.linear.x <<endl;


           // Go through this else statement 20 times 
           // so you can watch the robot come to stop before turning
           if (counter++ > 20)  
           {  
            Is_Fininsh_ = true;  
           }
        }

I see one possibility. Note you do not tell the robot to go 0.3m. You tell it go some velocity and then tell it to stop at some point in time after it has passed 0.3m. It's likely the code works as you expect. It passes 0.3m and then comes to a stop some distance later.

The question is how long after it has passed 0.3m does the condition

if ( line_travel < triagle_line1 )

get checked? It if gets checked when robot is at 0.4m and takes a 0.1m to stop, then it's working great.

If you provide the data that you print to the screen, but include the commanded velocity at each 'cout' statement, we'd have more to go on. You should change code so you can watch the robot come to stop prior to turning

More like this:

   if ( line_travel < triagle_line1 )  
        { 
            counter = 0; // init the counter
            controlVel_.angular.z = 0.0;
            controlVel_.linear.x  = vel_line_;
            controlVel_.linear.y  = 0;
            controlVel_.linear.z  = 0;  
            Is_Fininsh_ = false;  
            #ifdef VERBOSE
             cout<<"In IF statement: "<< curr_pos_.x <<"||"<< start_pos_.x<<"||  ||"<<curr_pos_.y<<"||"<<start_pos_.y<<"||  ||"<< line_travel <<"||  ||"<< line_travel << <<"||  ||"<< controlVel_.linear.x <<endl;
            #endif
        }  
        else  
        {   
            controlVel_.angular.z = 0.0;
            controlVel_.linear.x  = 0.0;
            controlVel_.linear.y  = 0;  
            controlVel_.linear.z  = 0;  
            state_ = 1;
            cout<<"In ELSE statement: "<< counter << "||"<< curr_pos_.x <<"||"<< start_pos_.x<<"||  ||"<<curr_pos_.y<<"||"<<start_pos_.y<<"||  ||"<< line_travel <<"||  ||"<< line_travel <<"||  ||" << controlVel_.linear.x <<endl;


           // Go through this else statement 20 times 
           // so you can watch the robot come to stop before turning
           if (counter++ > 20)  
           {  
            Is_Fininsh_ = true;  
           }
        }