I'm writing a method to send continued directions to a dobot. Code is C++:
bool moveBlockManually(tf2::Vector3 location, double rotation)
{
arm.moveToPositionWithLBlocking(location, rotation);
ros::Duration(1).sleep();
double new_location_x = location.x();
double new_location_y = location.y();
double new_location_z = location.z();
tf2::Vector3 nextPosition = tf2::Vector3(new_location_x,new_location_y, new_location_z);
string direction;
while(direction.compare("release") != 0){
cout << "Please enter a direction: ";
cin >> direction;
cout <<"you entered : " << direction << " \n";
if(direction.compare("up") == 0){
cout <<"moving up: " << " \n";
nextPosition.setZ(new_location_z + 5.0);
}else if(direction.compare("down") == 0){
cout <<"moving down: " << " \n";
nextPosition.setZ(new_location_z - 5.0);
}
arm.moveArmToPosition(nextPosition, 0);
}
return true;
}
but when calling this method, I enter "up" in command line, the robot move up, which is what I want, and ask for next direction. If I enter "up" again, nothing happens? Have someone an idea what I'm doing wrong?