|
|
|
|
@ -83,7 +83,7 @@ void FollowerClass::plane(global_location* target, global_location* leader, glob
|
|
|
|
|
y = slope * follower->lon + c;
|
|
|
|
|
|
|
|
|
|
// std::cout<< follower.ID << ","<< follower.lat <<","<< y <<std::endl;
|
|
|
|
|
std::cout<< "slope: " << slope <<std::endl;
|
|
|
|
|
// std::cout<< "slope: " << slope <<std::endl;
|
|
|
|
|
|
|
|
|
|
if((follower->lat <= y && phi < 180) || (follower->lat > y && phi >= 180)){
|
|
|
|
|
// std::cout <<"drone :"<<follower->ID <<", plane: 1" <<std::endl;
|
|
|
|
|
@ -298,20 +298,20 @@ int FollowerClass::find_ref_drone(global_location** data, size_t index, int lead
|
|
|
|
|
j+=1;
|
|
|
|
|
// std::cout << "drone3" <<std::endl;
|
|
|
|
|
}
|
|
|
|
|
// if(drone4.ID == data[1]->ID){
|
|
|
|
|
// self = drone4;
|
|
|
|
|
// }else{
|
|
|
|
|
// memberDrone[j] = drone4;
|
|
|
|
|
// j+=1;
|
|
|
|
|
// // std::cout << "drone4" <<std::endl;
|
|
|
|
|
// }
|
|
|
|
|
// if(drone5.ID == data[1]->ID){
|
|
|
|
|
// self = drone5;
|
|
|
|
|
// }else{
|
|
|
|
|
// memberDrone[j] = drone5;
|
|
|
|
|
// j+=1;
|
|
|
|
|
// // std::cout << "drone4" <<std::endl;
|
|
|
|
|
// }
|
|
|
|
|
if(drone4.ID == data[1]->ID){
|
|
|
|
|
self = drone4;
|
|
|
|
|
}else{
|
|
|
|
|
memberDrone[j] = drone4;
|
|
|
|
|
j+=1;
|
|
|
|
|
// std::cout << "drone4" <<std::endl;
|
|
|
|
|
}
|
|
|
|
|
if(drone5.ID == data[1]->ID){
|
|
|
|
|
self = drone5;
|
|
|
|
|
}else{
|
|
|
|
|
memberDrone[j] = drone5;
|
|
|
|
|
j+=1;
|
|
|
|
|
// std::cout << "drone4" <<std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<index-2;i++){
|
|
|
|
|
@ -343,7 +343,7 @@ int FollowerClass::find_ref_drone(global_location** data, size_t index, int lead
|
|
|
|
|
check_index = std::distance(_d.begin(),std::min_element(_d.begin(),_d.end())); //get minimum value's index
|
|
|
|
|
ref_ID = samePlane[check_index].ID;
|
|
|
|
|
|
|
|
|
|
std::cout <<"drone "<< self.ID <<",plane: "<< self.plane <<",refID: " << ref_ID << ",mem_index: "<< s_index << std::endl;
|
|
|
|
|
// std::cout <<"drone "<< self.ID <<",plane: "<< self.plane <<",refID: " << ref_ID << ",mem_index: "<< s_index << std::endl;
|
|
|
|
|
// std::cout <<"\n"<< std::endl;
|
|
|
|
|
return ref_ID;
|
|
|
|
|
|
|
|
|
|
@ -379,15 +379,15 @@ void FollowerClass::calculate_position(float k,float theta,int plane){
|
|
|
|
|
Pf[0]=(transfer[0][0]*Q[0]+transfer[0][1]*Q[1])*T[0]+Pl[0]/100;
|
|
|
|
|
Pf[1]=(transfer[1][0]*Q[0]+transfer[1][1]*Q[1])*T[1]+Pl[1]/100;
|
|
|
|
|
|
|
|
|
|
// error_lon = PID_x.update(follower_location.lon*1e5 , Pf[0] ,follower_pid); //caculate error (PID)
|
|
|
|
|
// error_lat = PID_y.update(follower_location.lat*1e5 , Pf[1] ,follower_pid);
|
|
|
|
|
error_lon = PID_x.update(follower_location.lon*1e5 , Pf[0] ,follower_pid); //caculate error (PID)
|
|
|
|
|
error_lat = PID_y.update(follower_location.lat*1e5 , Pf[1] ,follower_pid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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] );
|
|
|
|
|
|
|
|
|
|
error_lon = Pf[0] - (follower_location.lon*1e+5); //caculate error
|
|
|
|
|
error_lat = Pf[1] - (follower_location.lat*1e+5);
|
|
|
|
|
// error_lon = Pf[0] - (follower_location.lon*1e+5); //caculate error
|
|
|
|
|
// error_lat = Pf[1] - (follower_location.lat*1e+5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float error_degree = deg_phi - heading;
|
|
|
|
|
@ -449,7 +449,7 @@ void FollowerClass::face2target(global_location* target, global_location* leader
|
|
|
|
|
float x,y,target_heading;
|
|
|
|
|
float heading = GPS_object.get_heading();
|
|
|
|
|
heading_status = 0;
|
|
|
|
|
error_yaw = 0.2;
|
|
|
|
|
error_yaw = 0.25;
|
|
|
|
|
x = (target->lon/100) - (leader->lon/100);
|
|
|
|
|
y = (target->lat/100) - (leader->lat/100);
|
|
|
|
|
target_heading = ConvertDeg(x,y);
|
|
|
|
|
|