|
|
|
@ -65,10 +65,50 @@ void FormationClass::leader(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::leader1(float x,float y){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string command = "",pre_command = "";
|
|
|
|
|
|
|
|
std_msgs::String message;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leader_location=request_object.get_leader_GPS();
|
|
|
|
|
|
|
|
target_location.lon = leader_location.lon/100 + x;
|
|
|
|
|
|
|
|
target_location.lat = leader_location.lat/100 + y/1.1;
|
|
|
|
|
|
|
|
sleep(3);
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
|
|
heading_status = 0;
|
|
|
|
|
|
|
|
message.data = "1";
|
|
|
|
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
if(flag==0){
|
|
|
|
|
|
|
|
go2target(x,y);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
next_command.publish(message);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
|
|
|
|
while(command =="stop" || command == "land"){
|
|
|
|
|
|
|
|
command_object.set_velocity(0,0,0,0,1);
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command == "land"){
|
|
|
|
|
|
|
|
mode_object.set_Mode("LAND");
|
|
|
|
|
|
|
|
}else if(command != "stop"){
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command){
|
|
|
|
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pre_command = command;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::follower1(int type){
|
|
|
|
void FormationClass::follower1(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -86,7 +126,9 @@ void FormationClass::follower1(int type){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -103,7 +145,7 @@ void FormationClass::follower1(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::follower2(int type){
|
|
|
|
void FormationClass::follower2(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -121,7 +163,9 @@ void FormationClass::follower2(int type){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -134,7 +178,7 @@ void FormationClass::follower2(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::follower3(int type){
|
|
|
|
void FormationClass::follower3(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -153,7 +197,9 @@ void FormationClass::follower3(int type){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -166,7 +212,7 @@ void FormationClass::follower3(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::follower4(int type){
|
|
|
|
void FormationClass::follower4(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -184,12 +230,13 @@ void FormationClass::follower4(int type){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pre_command = command;
|
|
|
|
pre_command = command;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -197,7 +244,7 @@ void FormationClass::follower4(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::follower5(int type){
|
|
|
|
void FormationClass::follower5(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -215,7 +262,9 @@ void FormationClass::follower5(int type){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -228,7 +277,7 @@ void FormationClass::follower5(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::sph_follower1(int type){
|
|
|
|
void FormationClass::sph_follower1(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -245,7 +294,9 @@ void FormationClass::sph_follower1(int type){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -258,7 +309,7 @@ void FormationClass::sph_follower1(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::sph_follower2(int type){
|
|
|
|
void FormationClass::sph_follower2(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -275,12 +326,13 @@ void FormationClass::sph_follower2(int type){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pre_command = command;
|
|
|
|
pre_command = command;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -288,7 +340,7 @@ void FormationClass::sph_follower2(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::sph_follower3(int type){
|
|
|
|
void FormationClass::sph_follower3(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -305,7 +357,9 @@ void FormationClass::sph_follower3(int type){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -317,7 +371,7 @@ void FormationClass::sph_follower3(int type){
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::sph_follower4(int type){
|
|
|
|
void FormationClass::sph_follower4(int type){
|
|
|
|
|
|
|
|
|
|
|
|
std::string command,pre_command = "";
|
|
|
|
std::string message,command,pre_command = "";
|
|
|
|
while(true){
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
|
|
|
|
if(type == 0){
|
|
|
|
if(type == 0){
|
|
|
|
@ -334,7 +388,9 @@ void FormationClass::sph_follower4(int type){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
if(command != pre_command){
|
|
|
|
message = request_object.get_formation_message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command || message == "1"){
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -345,43 +401,7 @@ void FormationClass::sph_follower4(int type){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::leader1(float x,float y){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string command = "",pre_command = "";
|
|
|
|
|
|
|
|
leader_location=request_object.get_leader_GPS();
|
|
|
|
|
|
|
|
target_location.lon = leader_location.lon/100 + x;
|
|
|
|
|
|
|
|
target_location.lat = leader_location.lat/100 + y/1.1;
|
|
|
|
|
|
|
|
sleep(3);
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
|
|
heading_status = 0;
|
|
|
|
|
|
|
|
while(true){
|
|
|
|
|
|
|
|
if(flag==0){
|
|
|
|
|
|
|
|
go2target(x,y);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
next_command.publish("1");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
|
|
|
|
while(command =="stop" || command == "land"){
|
|
|
|
|
|
|
|
command_object.set_velocity(0,0,0,0,1);
|
|
|
|
|
|
|
|
command = receiver_object.check_command();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command == "land"){
|
|
|
|
|
|
|
|
mode_object.set_Mode("LAND");
|
|
|
|
|
|
|
|
}else if(command != "stop"){
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(command != pre_command){
|
|
|
|
|
|
|
|
// ROS_INFO("change formation");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pre_command = command;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormationClass::calculate_position(float k,float theta,int direction){
|
|
|
|
void FormationClass::calculate_position(float k,float theta,int direction){
|
|
|
|
|