uavlink test
This commit is contained in:
@@ -37,7 +37,7 @@ public:
|
|||||||
DroneStatus samePlane[5];
|
DroneStatus samePlane[5];
|
||||||
|
|
||||||
void follower(global_location* member_data, size_t index, int refID);
|
void follower(global_location* member_data, size_t index, int refID);
|
||||||
int find_ref_drone(global_location data[], size_t index, int leaderID);
|
int find_ref_drone(global_location* data[], size_t index, int leaderID);
|
||||||
|
|
||||||
float lon[3],lat[3];
|
float lon[3],lat[3];
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ private:
|
|||||||
float ignore_small = 0.50;
|
float ignore_small = 0.50;
|
||||||
|
|
||||||
void calculate_position(float k,float theta,int plane);
|
void calculate_position(float k,float theta,int plane);
|
||||||
void plane(global_location target, global_location leader, global_location follower);
|
void plane(global_location* target, global_location* leader, global_location* follower);
|
||||||
int direct(global_location target, global_location leader, DroneStatus self, DroneStatus member);
|
int direct(global_location* target, global_location* leader, DroneStatus self, DroneStatus member);
|
||||||
void choose_leader();
|
void choose_leader();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,23 +48,23 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
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(true){
|
||||||
|
|
||||||
// self = request_object.get_self_GPS();
|
self = request_object.get_self_GPS();
|
||||||
// M1 = request_object.get_M1_GPS();
|
M1 = request_object.get_M1_GPS();
|
||||||
// M2 = request_object.get_M2_GPS();
|
M2 = request_object.get_M2_GPS();
|
||||||
// M3 = request_object.get_M3_GPS();
|
M3 = request_object.get_M3_GPS();
|
||||||
// M4 = request_object.get_M4_GPS();
|
M4 = request_object.get_M4_GPS();
|
||||||
// pos[] = {target,self,M1,M2,M3,M4};
|
// pos[] = {target,self,M1,M2,M3,M4};
|
||||||
// member[] = {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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
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(true){
|
||||||
@@ -64,7 +64,7 @@ int main(int argc, char **argv) {
|
|||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
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(true){
|
||||||
@@ -64,7 +64,7 @@ int main(int argc, char **argv) {
|
|||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
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(true){
|
||||||
@@ -64,7 +64,7 @@ int main(int argc, char **argv) {
|
|||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
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(true){
|
||||||
@@ -64,7 +64,7 @@ int main(int argc, char **argv) {
|
|||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,80 +43,80 @@ void FollowerClass::follower(global_location* member_data, size_t index, int ref
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FollowerClass::plane(global_location target, global_location leader, global_location follower){
|
void FollowerClass::plane(global_location* target, global_location* leader, global_location* follower){
|
||||||
|
|
||||||
//caculate drone is locate on R/L plane
|
//caculate drone is locate on R/L plane
|
||||||
float slope,c,y;
|
float slope,c,y;
|
||||||
slope = (target.lat-leader.lat)/(target.lon-leader.lon);
|
slope = (target->lat-leader->lat)/(target->lon-leader->lon);
|
||||||
c = leader.lat - slope*leader.lon;
|
c = leader->lat - slope*leader->lon;
|
||||||
y = slope * follower.lon + c;
|
y = slope * follower->lon + c;
|
||||||
// std::cout<< follower.ID << ","<< follower.lat <<","<< y <<std::endl;
|
// std::cout<< follower.ID << ","<< follower.lat <<","<< y <<std::endl;
|
||||||
|
|
||||||
if(follower.lat <= y){
|
if(follower->lat <= y){
|
||||||
// std::cout<< follower.lat <<","<< y <<std::endl;
|
// std::cout<< follower.lat <<","<< y <<std::endl;
|
||||||
switch (follower.ID){
|
switch (follower->ID){
|
||||||
case 1:
|
case 1:
|
||||||
drone1.init_location.lat = follower.lat;
|
drone1.init_location.lat = follower->lat;
|
||||||
drone1.init_location.lon = follower.lon;
|
drone1.init_location.lon = follower->lon;
|
||||||
drone1.ID = follower.ID;
|
drone1.ID = follower->ID;
|
||||||
drone1.plane = 1; //right plane
|
drone1.plane = 1; //right plane
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
drone2.init_location.lat = follower.lat;
|
drone2.init_location.lat = follower->lat;
|
||||||
drone2.init_location.lon = follower.lon;
|
drone2.init_location.lon = follower->lon;
|
||||||
drone2.ID = follower.ID;
|
drone2.ID = follower->ID;
|
||||||
drone2.plane = 1;
|
drone2.plane = 1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
drone3.init_location.lat = follower.lat;
|
drone3.init_location.lat = follower->lat;
|
||||||
drone3.init_location.lon = follower.lon;
|
drone3.init_location.lon = follower->lon;
|
||||||
drone3.ID = follower.ID;
|
drone3.ID = follower->ID;
|
||||||
drone3.plane = 1;
|
drone3.plane = 1;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
drone4.init_location.lat = follower.lat;
|
drone4.init_location.lat = follower->lat;
|
||||||
drone4.init_location.lon = follower.lon;
|
drone4.init_location.lon = follower->lon;
|
||||||
drone4.ID = follower.ID;
|
drone4.ID = follower->ID;
|
||||||
drone4.plane = 1;
|
drone4.plane = 1;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
drone5.init_location.lat = follower.lat;
|
drone5.init_location.lat = follower->lat;
|
||||||
drone5.init_location.lon = follower.lon;
|
drone5.init_location.lon = follower->lon;
|
||||||
drone5.ID = follower.ID;
|
drone5.ID = follower->ID;
|
||||||
drone5.plane = 1;
|
drone5.plane = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if(follower.lat > y){
|
}else if(follower->lat > y){
|
||||||
// std::cout<< follower.lat <<","<< y <<std::endl;
|
// std::cout<< follower.lat <<","<< y <<std::endl;
|
||||||
switch (follower.ID){
|
switch (follower->ID){
|
||||||
case 1:
|
case 1:
|
||||||
drone1.init_location.lat = follower.lat;
|
drone1.init_location.lat = follower->lat;
|
||||||
drone1.init_location.lon = follower.lon;
|
drone1.init_location.lon = follower->lon;
|
||||||
drone1.ID = follower.ID;
|
drone1.ID = follower->ID;
|
||||||
drone1.plane = -1; //left plane
|
drone1.plane = -1; //left plane
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
drone2.init_location.lat = follower.lat;
|
drone2.init_location.lat = follower->lat;
|
||||||
drone2.init_location.lon = follower.lon;
|
drone2.init_location.lon = follower->lon;
|
||||||
drone2.ID = follower.ID;
|
drone2.ID = follower->ID;
|
||||||
drone2.plane = -1;
|
drone2.plane = -1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
drone3.init_location.lat = follower.lat;
|
drone3.init_location.lat = follower->lat;
|
||||||
drone3.init_location.lon = follower.lon;
|
drone3.init_location.lon = follower->lon;
|
||||||
drone3.ID = follower.ID;
|
drone3.ID = follower->ID;
|
||||||
drone3.plane = -1;
|
drone3.plane = -1;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
drone4.init_location.lat = follower.lat;
|
drone4.init_location.lat = follower->lat;
|
||||||
drone4.init_location.lon = follower.lon;
|
drone4.init_location.lon = follower->lon;
|
||||||
drone4.ID = follower.ID;
|
drone4.ID = follower->ID;
|
||||||
drone4.plane = -1;
|
drone4.plane = -1;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
drone5.init_location.lat = follower.lat;
|
drone5.init_location.lat = follower->lat;
|
||||||
drone5.init_location.lon = follower.lon;
|
drone5.init_location.lon = follower->lon;
|
||||||
drone5.ID = follower.ID;
|
drone5.ID = follower->ID;
|
||||||
drone5.plane = -1;
|
drone5.plane = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -125,12 +125,12 @@ void FollowerClass::plane(global_location target, global_location leader, global
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FollowerClass::direct(global_location target, global_location leader, DroneStatus self, DroneStatus member){
|
int FollowerClass::direct(global_location* target, global_location* leader, DroneStatus self, DroneStatus member){
|
||||||
|
|
||||||
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)
|
||||||
vector_SM.lat = member.init_location.lat - self.init_location.lat;
|
vector_SM.lat = member.init_location.lat - self.init_location.lat;
|
||||||
k = (vector_LT.lon*vector_SM.lon)+(vector_LT.lat*vector_SM.lat); //k = vector_LT dot vector_SM
|
k = (vector_LT.lon*vector_SM.lon)+(vector_LT.lat*vector_SM.lat); //k = vector_LT dot vector_SM
|
||||||
@@ -146,40 +146,40 @@ int FollowerClass::direct(global_location target, global_location leader, DroneS
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FollowerClass::find_ref_drone(global_location data[], size_t index, int leaderID){
|
int FollowerClass::find_ref_drone(global_location* data[], size_t index, int leaderID){
|
||||||
|
|
||||||
for(int i=1 ; i<index ; i++){ //check leader drone
|
for(int i=1 ; i<index ; i++){ //check leader drone
|
||||||
if(leaderID == data[i].ID){
|
if(leaderID == data[i]->ID){
|
||||||
leader_drone = data[i];
|
leader_drone = *data[i];
|
||||||
switch(leaderID){
|
switch(leaderID){
|
||||||
case 1:
|
case 1:
|
||||||
drone1.init_location.lat = data[i].lat;
|
drone1.init_location.lat = data[i]->lat;
|
||||||
drone1.init_location.lon = data[i].lon;
|
drone1.init_location.lon = data[i]->lon;
|
||||||
drone1.ID = data[i].ID;
|
drone1.ID = data[i]->ID;
|
||||||
drone1.plane = 0; //center
|
drone1.plane = 0; //center
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
drone2.init_location.lat = data[i].lat;
|
drone2.init_location.lat = data[i]->lat;
|
||||||
drone2.init_location.lon = data[i].lon;
|
drone2.init_location.lon = data[i]->lon;
|
||||||
drone2.ID = data[i].ID;
|
drone2.ID = data[i]->ID;
|
||||||
drone2.plane = 0;
|
drone2.plane = 0;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
drone3.init_location.lat = data[i].lat;
|
drone3.init_location.lat = data[i]->lat;
|
||||||
drone3.init_location.lon = data[i].lon;
|
drone3.init_location.lon = data[i]->lon;
|
||||||
drone3.ID = data[i].ID;
|
drone3.ID = data[i]->ID;
|
||||||
drone3.plane = 0;
|
drone3.plane = 0;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
drone4.init_location.lat = data[i].lat;
|
drone4.init_location.lat = data[i]->lat;
|
||||||
drone4.init_location.lon = data[i].lon;
|
drone4.init_location.lon = data[i]->lon;
|
||||||
drone4.ID = data[i].ID;
|
drone4.ID = data[i]->ID;
|
||||||
drone4.plane = 0;
|
drone4.plane = 0;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
drone5.init_location.lat = data[i].lat;
|
drone5.init_location.lat = data[i]->lat;
|
||||||
drone5.init_location.lon = data[i].lon;
|
drone5.init_location.lon = data[i]->lon;
|
||||||
drone5.ID = data[i].ID;
|
drone5.ID = data[i]->ID;
|
||||||
drone5.plane = 0;
|
drone5.plane = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -189,41 +189,41 @@ int FollowerClass::find_ref_drone(global_location data[], size_t index, int lead
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i=1 ; i<index ; i++){
|
for(int i=1 ; i<index ; i++){
|
||||||
if(data[i].ID != leader_drone.ID){ //caculate the plane of each drone
|
if(data[i]->ID != leader_drone.ID){ //caculate the plane of each drone
|
||||||
plane(data[0],leader_drone,data[i]);
|
plane(data[0],&leader_drone,data[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int j=0,s_index=0;
|
int j=0,s_index=0;
|
||||||
if(drone1.ID == data[1].ID){ //seperate self and other
|
if(drone1.ID == data[1]->ID){ //seperate self and other
|
||||||
self = drone1; //problem
|
self = drone1; //problem
|
||||||
}else{
|
}else{
|
||||||
memberDrone[j] = drone1;
|
memberDrone[j] = drone1;
|
||||||
j+=1;
|
j+=1;
|
||||||
// std::cout << "drone1" <<std::endl;
|
// std::cout << "drone1" <<std::endl;
|
||||||
}
|
}
|
||||||
if(drone2.ID == data[1].ID){
|
if(drone2.ID == data[1]->ID){
|
||||||
self = drone2;
|
self = drone2;
|
||||||
}else{
|
}else{
|
||||||
memberDrone[j] = drone2;
|
memberDrone[j] = drone2;
|
||||||
j+=1;
|
j+=1;
|
||||||
// std::cout << "drone2" <<std::endl;
|
// std::cout << "drone2" <<std::endl;
|
||||||
}
|
}
|
||||||
if(drone3.ID == data[1].ID){
|
if(drone3.ID == data[1]->ID){
|
||||||
self = drone3;
|
self = drone3;
|
||||||
}else{
|
}else{
|
||||||
memberDrone[j] = drone3;
|
memberDrone[j] = drone3;
|
||||||
j+=1;
|
j+=1;
|
||||||
// std::cout << "drone3" <<std::endl;
|
// std::cout << "drone3" <<std::endl;
|
||||||
}
|
}
|
||||||
if(drone4.ID == data[1].ID){
|
if(drone4.ID == data[1]->ID){
|
||||||
self = drone4;
|
self = drone4;
|
||||||
}else{
|
}else{
|
||||||
memberDrone[j] = drone4;
|
memberDrone[j] = drone4;
|
||||||
j+=1;
|
j+=1;
|
||||||
// std::cout << "drone4" <<std::endl;
|
// std::cout << "drone4" <<std::endl;
|
||||||
}
|
}
|
||||||
if(drone5.ID == data[1].ID){
|
if(drone5.ID == data[1]->ID){
|
||||||
self = drone5;
|
self = drone5;
|
||||||
}else{
|
}else{
|
||||||
memberDrone[j] = drone5;
|
memberDrone[j] = drone5;
|
||||||
@@ -249,7 +249,7 @@ int FollowerClass::find_ref_drone(global_location data[], size_t index, int lead
|
|||||||
// std::cout <<"s_index " <<s_index <<std::endl;
|
// std::cout <<"s_index " <<s_index <<std::endl;
|
||||||
for(int i=0 ; i<s_index ; i++){ //caculate each same plane mamber's distance
|
for(int i=0 ; i<s_index ; i++){ //caculate each same plane mamber's distance
|
||||||
|
|
||||||
dir = direct(data[0],leader_drone,self,samePlane[i]);
|
dir = direct(data[0],&leader_drone,self,samePlane[i]);
|
||||||
d[i] = dir * sqrt( pow((self.init_location.lat - samePlane[i].init_location.lat ),2) + pow((self.init_location.lon - samePlane[i].init_location.lon),2) );
|
d[i] = dir * sqrt( pow((self.init_location.lat - samePlane[i].init_location.lat ),2) + pow((self.init_location.lon - samePlane[i].init_location.lon),2) );
|
||||||
|
|
||||||
// std::cout << i<<"," <<d[i] <<std::endl;
|
// std::cout << i<<"," <<d[i] <<std::endl;
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ if __name__ == '__main__':
|
|||||||
FilePath = os.path.join(os.path.dirname(__file__),"utils","mqttConfig_PUB5.yml")
|
FilePath = os.path.join(os.path.dirname(__file__),"utils","mqttConfig_PUB5.yml")
|
||||||
cfg = utils.Read_PUB_Config(FilePath)
|
cfg = utils.Read_PUB_Config(FilePath)
|
||||||
client = utils.MQTTClient(cfg.MQTTClientNamePub)
|
client = utils.MQTTClient(cfg.MQTTClientNamePub)
|
||||||
|
|
||||||
# set log
|
# set log
|
||||||
log_format = "%(asctime)s - %(levelname)s - %(message)s"
|
log_format = "%(asctime)s - %(levelname)s - %(message)s"
|
||||||
formatter = logging.Formatter(log_format)
|
formatter = logging.Formatter(log_format)
|
||||||
@@ -78,7 +77,8 @@ if __name__ == '__main__':
|
|||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
logger.addHandler(stream_handler)
|
logger.addHandler(stream_handler)
|
||||||
logger.info(cfg)
|
# logger.info(cfg)
|
||||||
|
print(cfg.keepalive)
|
||||||
|
|
||||||
# Mqtt
|
# Mqtt
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
|
|||||||
@@ -259,9 +259,6 @@ int main(int argc,char** argv){
|
|||||||
|
|
||||||
global_location data[]={target,self,M1,M2};
|
global_location data[]={target,self,M1,M2};
|
||||||
size_t index = sizeof(data)/sizeof(data[0]);
|
size_t index = sizeof(data)/sizeof(data[0]);
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
int* arr[] = {&x,&y};
|
|
||||||
|
|
||||||
|
|
||||||
find_ref_drone(data,index,check_leader(data,index).leader_ID);
|
find_ref_drone(data,index,check_leader(data,index).leader_ID);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from geometry_msgs.msg import Vector3
|
|||||||
def init_dataFormat(cfg:Read_PUB_Config):
|
def init_dataFormat(cfg:Read_PUB_Config):
|
||||||
ros_namespace="/drone1"
|
ros_namespace="/drone1"
|
||||||
f1data = b'\xf1drone550..............\r\n'
|
f1data = b'\xf1drone550..............\r\n'
|
||||||
sel = serial.Serial(cfg.port, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE)
|
sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE)
|
||||||
sel.write(f1data)
|
sel.write(f1data)
|
||||||
Proto_msg_from_ros.sel = sel
|
Proto_msg_from_ros.sel = sel
|
||||||
Proto_msg_from_ros.flight_information_msg = flight_information_pb2.flight_information_message()
|
Proto_msg_from_ros.flight_information_msg = flight_information_pb2.flight_information_message()
|
||||||
|
|||||||
@@ -13,3 +13,4 @@ ROS:
|
|||||||
ROStopicName_Cmd_Broadcast_Receiver: cmd_receiver
|
ROStopicName_Cmd_Broadcast_Receiver: cmd_receiver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: cmd.log
|
logFileName: cmd.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -20,3 +20,4 @@ ROS:
|
|||||||
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: pub.log
|
logFileName: pub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -20,3 +20,4 @@ ROS:
|
|||||||
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: pub.log
|
logFileName: pub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -20,3 +20,4 @@ ROS:
|
|||||||
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: pub.log
|
logFileName: pub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -20,3 +20,4 @@ ROS:
|
|||||||
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: pub.log
|
logFileName: pub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -20,3 +20,4 @@ ROS:
|
|||||||
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: pub.log
|
logFileName: pub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -35,3 +35,4 @@ ROS:
|
|||||||
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: sub.log
|
logFileName: sub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -35,3 +35,4 @@ ROS:
|
|||||||
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: sub.log
|
logFileName: sub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -34,3 +34,4 @@ ROS:
|
|||||||
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: sub.log
|
logFileName: sub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -36,3 +36,4 @@ ROS:
|
|||||||
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: sub.log
|
logFileName: sub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -36,3 +36,4 @@ ROS:
|
|||||||
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
Dron555_ROStopicName_Flight_Information: Dron555_Flight_Information_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: sub.log
|
logFileName: sub.log
|
||||||
|
UAVLINK: "None"
|
||||||
@@ -65,7 +65,7 @@ class Read_PUB_Config(Config):
|
|||||||
"msg_format": (str,False),
|
"msg_format": (str,False),
|
||||||
"uav_id": (str,False),
|
"uav_id": (str,False),
|
||||||
"baudrate": (int,False),
|
"baudrate": (int,False),
|
||||||
"port": (str,False)}}
|
"ttyport": (str,False)}}
|
||||||
self.setAttribute()
|
self.setAttribute()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ UAVLINK:
|
|||||||
msg_format: Proto
|
msg_format: Proto
|
||||||
uav_id: \x01\x01
|
uav_id: \x01\x01
|
||||||
baudrate: 250000
|
baudrate: 250000
|
||||||
port: /dev/ttyUSB0
|
ttyport: /dev/ttyUSB0
|
||||||
MQTT: "None"
|
MQTT: "None"
|
||||||
#ROS
|
#ROS
|
||||||
ROS:
|
ROS:
|
||||||
|
|||||||
Reference in New Issue
Block a user