add find_reference_drone function(unfinished)
This commit is contained in:
@@ -2,10 +2,16 @@
|
||||
#include "class_model/DroneStatus.h"
|
||||
#include <iterator>
|
||||
|
||||
bool is_leader(global_location data[], size_t index){
|
||||
typedef struct result{
|
||||
int leader_ID;
|
||||
bool is_leader;
|
||||
}result;
|
||||
|
||||
result check_leader(global_location data[], size_t index){
|
||||
|
||||
float d[index];
|
||||
int check_ID,leader_ID;
|
||||
int check_ID;
|
||||
result _result;
|
||||
|
||||
for(int i=1 ; i<index ; i++){
|
||||
|
||||
@@ -17,14 +23,16 @@ bool is_leader(global_location data[], size_t index){
|
||||
std::vector<float> _d(d+1,d+index-1);
|
||||
|
||||
check_ID = std::distance(_d.begin(),std::min_element(_d.begin(),_d.end())); //get minimum value's index
|
||||
leader_ID = check_ID + 1;
|
||||
_result.leader_ID = check_ID + 1;
|
||||
|
||||
std::cout <<"Drone " << leader_ID << " is leader " << std::endl;
|
||||
std::cout <<"Drone " << _result.leader_ID << " is leader " << std::endl;
|
||||
|
||||
if (data[1].ID == leader_ID){
|
||||
return 1;
|
||||
if (data[1].ID == _result.leader_ID){
|
||||
_result.is_leader = 1;
|
||||
return _result;
|
||||
}else{
|
||||
return 0;
|
||||
_result.is_leader = 0;
|
||||
return _result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,9 @@ public:
|
||||
DroneStatus drone1;
|
||||
DroneStatus drone2;
|
||||
DroneStatus drone3;
|
||||
|
||||
DroneStatus self;
|
||||
DroneStatus samePlane[3];
|
||||
|
||||
void follower();
|
||||
|
||||
float lon[3],lat[3];
|
||||
@@ -37,9 +39,12 @@ private:
|
||||
global_location target_location;
|
||||
global_location follower_location;
|
||||
global_location leader_location;
|
||||
global_location leader_drone;
|
||||
DroneStatus memberDrone[];
|
||||
|
||||
void calculate_position(float k,float theta);
|
||||
void plane(global_location target_location,global_location leader_location,global_location follower_location);
|
||||
void plane(global_location target, global_location leader, global_location follower);
|
||||
void find_ref_drone(global_location data[], size_t index, int leaderID);
|
||||
void choose_leader();
|
||||
void follow();
|
||||
void get_location();
|
||||
|
||||
Reference in New Issue
Block a user