Add class "PubInfo" to publish drone's formation type and mission.
parent
4bd113c30c
commit
542ef22120
@ -0,0 +1,14 @@
|
||||
#ifndef INFO_H
|
||||
#define INFO_H
|
||||
|
||||
#include<std/string.hpp>
|
||||
|
||||
typedef struct flight_INFO
|
||||
{
|
||||
std::string type, //type include drone's formation. ex: V , X ,| ......
|
||||
mission; //The mission is what we want the drone to do.
|
||||
}INFO;
|
||||
|
||||
|
||||
|
||||
#endif INFO_H
|
||||
@ -0,0 +1,31 @@
|
||||
/*Publish Drone's status to topic "Flight_Information_reciver"*/
|
||||
#ifndef PUBINFO_H
|
||||
#define PUBINFO_H
|
||||
|
||||
#include <ros/ros.h>
|
||||
#include <diagnostic_msgs/KeyValue.h>
|
||||
#include "class_model/INFO.h"
|
||||
|
||||
|
||||
class PubInfoClass {
|
||||
public:
|
||||
PubInfoClass();
|
||||
virtual ~PubInfoClass();
|
||||
void pub_info(INFO msg);
|
||||
|
||||
|
||||
private:
|
||||
// ROS NodeHandle
|
||||
ros::NodeHandle node_handle_;
|
||||
|
||||
//SUBSCRIBE
|
||||
|
||||
//PUBLISH
|
||||
ros::Publisher PubInfo;
|
||||
INFO msg;
|
||||
diagnostic_msgs::KeyValue info;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // PUBINFO_H
|
||||
@ -0,0 +1,22 @@
|
||||
#include "class_model/PubInfo.h"
|
||||
|
||||
PubInfoClass::PubInfoClass():node_handle_("~"){
|
||||
|
||||
std::string ros_namespace;
|
||||
if (!node_handle_.hasParam("namespace"))
|
||||
{
|
||||
}else{
|
||||
node_handle_.getParam("namespace", ros_namespace);
|
||||
}
|
||||
PubInfo = node_handle_.advertise<diagnostic_msgs::KeyValue>(ros_namespace+"/Flight_Information_reciver",100);
|
||||
|
||||
}
|
||||
|
||||
PubInfoClass::~PubInfoClass() { ros::shutdown(); }
|
||||
|
||||
void PubInfoClass::pub_info(INFO msg){
|
||||
info.key = msg.type; //key == drone's formation
|
||||
info.value = msg.mission; //value == drone's mission
|
||||
PubInfo.publish(info);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue