|
|
|
@ -129,6 +129,7 @@ int FollowerClass::direct(global_location* target, global_location* leader, Dron
|
|
|
|
|
|
|
|
|
|
|
|
global_location vector_LT,vector_SM;
|
|
|
|
global_location vector_LT,vector_SM;
|
|
|
|
float m,n,k,cosTheta;
|
|
|
|
float m,n,k,cosTheta;
|
|
|
|
|
|
|
|
|
|
|
|
vector_LT.lon = target->lon - leader->lon; //vector_LT (leader->target)
|
|
|
|
vector_LT.lon = target->lon - leader->lon; //vector_LT (leader->target)
|
|
|
|
vector_LT.lat = target->lat - leader->lat;
|
|
|
|
vector_LT.lat = target->lat - leader->lat;
|
|
|
|
vector_SM.lon = member.init_location.lon - self.init_location.lon; //vector_SM (self->member)
|
|
|
|
vector_SM.lon = member.init_location.lon - self.init_location.lon; //vector_SM (self->member)
|
|
|
|
@ -261,7 +262,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
|
|
|
|
check_index = std::distance(_d.begin(),std::min_element(_d.begin(),_d.end())); //get minimum value's index
|
|
|
|
ref_ID = samePlane[check_index].ID;
|
|
|
|
ref_ID = samePlane[check_index].ID;
|
|
|
|
|
|
|
|
|
|
|
|
// std::cout <<"drone "<< self.ID <<",plane: "<< self.plane <<",refID: " << ref_ID << std::endl;
|
|
|
|
std::cout <<"drone "<< self.ID <<",plane: "<< self.plane <<",refID: " << ref_ID << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
return ref_ID;
|
|
|
|
return ref_ID;
|
|
|
|
|
|
|
|
|
|
|
|
@ -291,15 +292,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[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;
|
|
|
|
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_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_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_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] );
|
|
|
|
|
|
|
|
|
|
|
|
// error_lon = Pf[0] - (follower_location.lon*1e+5); //caculate error
|
|
|
|
error_lon = Pf[0] - (follower_location.lon*1e+5); //caculate error
|
|
|
|
// error_lat = Pf[1] - (follower_location.lat*1e+5);
|
|
|
|
error_lat = Pf[1] - (follower_location.lat*1e+5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float error_degree = deg_phi - heading;
|
|
|
|
float error_degree = deg_phi - heading;
|
|
|
|
|