|
|
|
@ -18,11 +18,12 @@ int main(int argc, char **argv) {
|
|
|
|
RequestClass request_object;
|
|
|
|
RequestClass request_object;
|
|
|
|
FollowerClass follower_object;
|
|
|
|
FollowerClass follower_object;
|
|
|
|
LeaderClass leader_object;
|
|
|
|
LeaderClass leader_object;
|
|
|
|
|
|
|
|
ReceiverClass receiver_object;
|
|
|
|
|
|
|
|
|
|
|
|
// SelectionClass selection_object;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global_location target,self,M1,M2,M3,M4;
|
|
|
|
global_location target,self,M1,M2,M3,M4;
|
|
|
|
int ref_ID,checkLeader;
|
|
|
|
int ref_ID,checkLeader,flag;
|
|
|
|
|
|
|
|
std::string type = "",pre_type ="x";
|
|
|
|
|
|
|
|
|
|
|
|
YAML::Node config = YAML::LoadFile("/home/dodo/ardupilot_ws/src/class_model/src/config.yaml"); //reading yaml parameter(target point)
|
|
|
|
YAML::Node config = YAML::LoadFile("/home/dodo/ardupilot_ws/src/class_model/src/config.yaml"); //reading yaml parameter(target point)
|
|
|
|
target.lon = config["routh1"]["x"].as<float>()*1e7;
|
|
|
|
target.lon = config["routh1"]["x"].as<float>()*1e7;
|
|
|
|
@ -35,8 +36,7 @@ int main(int argc, char **argv) {
|
|
|
|
M3 = request_object.get_M3_GPS();
|
|
|
|
M3 = request_object.get_M3_GPS();
|
|
|
|
M4 = request_object.get_M4_GPS();
|
|
|
|
M4 = request_object.get_M4_GPS();
|
|
|
|
|
|
|
|
|
|
|
|
// global_location pos[] = {target,self,M1,M2};
|
|
|
|
|
|
|
|
// global_location member[] = {M1,M2};
|
|
|
|
|
|
|
|
global_location* pos[] = {&target,&self,&M1,&M2,&M3,&M4};
|
|
|
|
global_location* pos[] = {&target,&self,&M1,&M2,&M3,&M4};
|
|
|
|
global_location* member[] = {&M1,&M2,&M3,&M4};
|
|
|
|
global_location* member[] = {&M1,&M2,&M3,&M4};
|
|
|
|
size_t index = sizeof(pos)/sizeof(pos[0]);
|
|
|
|
size_t index = sizeof(pos)/sizeof(pos[0]);
|
|
|
|
@ -45,28 +45,44 @@ int main(int argc, char **argv) {
|
|
|
|
mode_object.set_Mode("GUIDED");
|
|
|
|
mode_object.set_Mode("GUIDED");
|
|
|
|
control_object.arm();
|
|
|
|
control_object.arm();
|
|
|
|
control_object.takeoff(2);
|
|
|
|
control_object.takeoff(2);
|
|
|
|
|
|
|
|
// while(flag!=1){
|
|
|
|
|
|
|
|
// type = receiver_object.check_command();
|
|
|
|
|
|
|
|
// if(type == "go"){
|
|
|
|
|
|
|
|
// mode_object.set_Mode("GUIDED");
|
|
|
|
|
|
|
|
// control_object.arm();
|
|
|
|
|
|
|
|
// control_object.takeoff(2);
|
|
|
|
|
|
|
|
// sleep(2);
|
|
|
|
|
|
|
|
// flag = 1;
|
|
|
|
|
|
|
|
// type ="";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
checkLeader = check_leader(*pos,index).is_leader;
|
|
|
|
checkLeader = check_leader(*pos,index).is_leader;
|
|
|
|
if(checkLeader != 1){
|
|
|
|
if(checkLeader != 1){
|
|
|
|
ref_ID = follower_object.find_ref_drone(pos,index,check_leader(*pos,index).leader_ID); //find_ref_drone(pos,index,leader_ID);
|
|
|
|
ref_ID = follower_object.find_ref_drone(pos,index,check_leader(*pos,index).leader_ID); //find_ref_drone(pos,index,leader_ID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while(true){
|
|
|
|
while(ros::ok()&& flag == 1){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type = receiver_object.check_command();
|
|
|
|
|
|
|
|
self = request_object.get_self_GPS();
|
|
|
|
|
|
|
|
M1 = request_object.get_M1_GPS();
|
|
|
|
|
|
|
|
M2 = request_object.get_M2_GPS();
|
|
|
|
|
|
|
|
M3 = request_object.get_M3_GPS();
|
|
|
|
|
|
|
|
M4 = request_object.get_M4_GPS();
|
|
|
|
|
|
|
|
|
|
|
|
// self = request_object.get_self_GPS();
|
|
|
|
|
|
|
|
// M1 = request_object.get_M1_GPS();
|
|
|
|
|
|
|
|
// M2 = request_object.get_M2_GPS();
|
|
|
|
|
|
|
|
// M3 = request_object.get_M3_GPS();
|
|
|
|
|
|
|
|
// M4 = request_object.get_M4_GPS();
|
|
|
|
|
|
|
|
// pos[] = {target,self,M1,M2,M3,M4};
|
|
|
|
|
|
|
|
// member[] = {M1,M2,M3,M4};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(checkLeader == 1){
|
|
|
|
if(checkLeader == 1){
|
|
|
|
// leader_object.leader(target);
|
|
|
|
leader_object.leader(target);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
ref_ID = follower_object.find_ref_drone(pos,index,check_leader(*pos,index).leader_ID);
|
|
|
|
ref_ID = follower_object.find_ref_drone(pos,index,check_leader(*pos,index).leader_ID);
|
|
|
|
follower_object.follower(*member,m_index,ref_ID); //follow reference drone position
|
|
|
|
follower_object.follower(member,m_index,ref_ID); //follow reference drone position
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if(type == "land"){
|
|
|
|
|
|
|
|
// mode_object.set_Mode("LAND");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ros::waitForShutdown();
|
|
|
|
ros::waitForShutdown();
|
|
|
|
|
|
|
|
|
|
|
|
|