|
|
|
@ -437,8 +437,8 @@ void FormationClass::calculate_position(float k,float theta,int direction){
|
|
|
|
// float error_x = PID_x.update1(follower_location.lon*1e5 , Pf[0] ); //caculate error
|
|
|
|
// float error_x = PID_x.update1(follower_location.lon*1e5 , Pf[0] ); //caculate error
|
|
|
|
// float error_y = PID_y.update1(follower_location.lat*1e5 , Pf[1] );
|
|
|
|
// float error_y = PID_y.update1(follower_location.lat*1e5 , Pf[1] );
|
|
|
|
|
|
|
|
|
|
|
|
// float error_x = Pf[0] - (follower_location.lon*1e+5); //caculate error
|
|
|
|
float error_lon = Pf[0] - (follower_location.lon*1e+5); //caculate error
|
|
|
|
// float error_y = Pf[1] - (follower_location.lat*1e+5);
|
|
|
|
float error_lat = Pf[1] - (follower_location.lat*1e+5);
|
|
|
|
|
|
|
|
|
|
|
|
float error_degree = deg_phi - heading + direction;
|
|
|
|
float error_degree = deg_phi - heading + direction;
|
|
|
|
float error_yaw = 0.2; //CCW
|
|
|
|
float error_yaw = 0.2; //CCW
|
|
|
|
@ -452,11 +452,11 @@ void FormationClass::calculate_position(float k,float theta,int direction){
|
|
|
|
|
|
|
|
|
|
|
|
error_yaw = check_direction(error_degree)*error_yaw; //check yaw direction
|
|
|
|
error_yaw = check_direction(error_degree)*error_yaw; //check yaw direction
|
|
|
|
|
|
|
|
|
|
|
|
if (error_x < 0.3 && error_x > -0.3){ //ignore small errors
|
|
|
|
if (error_lon < ignore_small && error_lon > -ignore_small){ //ignore small errors
|
|
|
|
error_x = 0;
|
|
|
|
error_lon = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error_y < 0.3 && error_y > -0.3){
|
|
|
|
if (error_lat < ignore_small && error_lat > -ignore_small){
|
|
|
|
error_y = 0;
|
|
|
|
error_lat = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error_degree < 5 && error_degree > -5 ){
|
|
|
|
if (error_degree < 5 && error_degree > -5 ){
|
|
|
|
error_yaw = 0;
|
|
|
|
error_yaw = 0;
|
|
|
|
@ -464,17 +464,18 @@ void FormationClass::calculate_position(float k,float theta,int direction){
|
|
|
|
error_yaw = 0;
|
|
|
|
error_yaw = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ROS_INFO("%f,%f",leader_location.lon/100 ,leader_location.lat/100);
|
|
|
|
ROS_INFO("%f,%f",leader_location.lon/100 ,leader_location.lat/100);
|
|
|
|
// ROS_INFO("%f,%f",follower_location.lon*1e+5 ,follower_location.lat*1e+5);
|
|
|
|
ROS_INFO("%f,%f",follower_location.lon*1e+5 ,follower_location.lat*1e+5);
|
|
|
|
// ROS_INFO("%f,%f",Pf[0],Pf[1]);
|
|
|
|
ROS_INFO("%f,%f",Pf[0],Pf[1]);
|
|
|
|
// ROS_INFO("%f,%f",error_x,error_y);
|
|
|
|
ROS_INFO("%f,%f",error_x,error_y);
|
|
|
|
|
|
|
|
ROS_INFO("%f,%f",error_lon,error_lat);
|
|
|
|
// ROS_INFO("deg:%f",deg_phi);
|
|
|
|
// ROS_INFO("deg:%f",deg_phi);
|
|
|
|
// ROS_INFO("heading:%f",heading);
|
|
|
|
// ROS_INFO("heading:%f",heading);
|
|
|
|
// ROS_INFO("error_degree:%f",error_degree);
|
|
|
|
// ROS_INFO("error_degree:%f",error_degree);
|
|
|
|
// ROS_INFO("error_yaw:%f",error_yaw);
|
|
|
|
// ROS_INFO("error_yaw:%f",error_yaw);
|
|
|
|
// ROS_INFO("************************************");
|
|
|
|
// ROS_INFO("************************************");
|
|
|
|
|
|
|
|
|
|
|
|
command_object.set_velocity(error_x,error_y,0,error_yaw,0.1);
|
|
|
|
command_object.set_velocity(error_lon,error_lat,0,error_yaw,0.1);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -548,7 +549,7 @@ void FormationClass::spherical_coordinate(float k,float theta,float psi){
|
|
|
|
// ROS_INFO("%f,%f",leader_location.lon/100 ,leader_location.lat/100);
|
|
|
|
// ROS_INFO("%f,%f",leader_location.lon/100 ,leader_location.lat/100);
|
|
|
|
// ROS_INFO("%f,%f",follower_location.lon*1e+5 ,follower_location.lat*1e+5);
|
|
|
|
// ROS_INFO("%f,%f",follower_location.lon*1e+5 ,follower_location.lat*1e+5);
|
|
|
|
// ROS_INFO("%f,%f",Pf[0],Pf[1]);
|
|
|
|
// ROS_INFO("%f,%f",Pf[0],Pf[1]);
|
|
|
|
// ROS_INFO("%f,%f",error_x,error_y);
|
|
|
|
ROS_INFO("%f,%f",error_x,error_y);
|
|
|
|
// ROS_INFO("deg:%f",deg_phi);
|
|
|
|
// ROS_INFO("deg:%f",deg_phi);
|
|
|
|
// ROS_INFO("heading:%f",heading);
|
|
|
|
// ROS_INFO("heading:%f",heading);
|
|
|
|
// ROS_INFO("error_degree:%f",error_degree);
|
|
|
|
// ROS_INFO("error_degree:%f",error_degree);
|
|
|
|
|