ROSBuzz_MISTLab/include/roscontroller.h

107 lines
2.6 KiB
C
Raw Normal View History

#pragma once
#include "ros/ros.h"
#include "sensor_msgs/NavSatFix.h"
#include "mavros_msgs/GlobalPositionTarget.h"
#include "mavros_msgs/CommandCode.h"
#include "mavros_msgs/CommandInt.h"
2016-11-18 15:05:31 -04:00
#include "mavros_msgs/ExtendedState.h"
#include "mavros_msgs/State.h"
#include "mavros_msgs/BatteryStatus.h"
#include "mavros_msgs/Mavlink.h"
#include "sensor_msgs/NavSatStatus.h"
#include <sstream>
#include <buzz/buzzasm.h>
#include "buzzuav_closures.h"
#include "buzz_utility.h"
#include "uav_utility.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <signal.h>
#include <ostream>
#include <map>
using namespace std;
namespace rosbzz_node{
class roscontroller{
public:
roscontroller();
~roscontroller();
//void RosControllerInit();
void RosControllerRun();
2016-11-14 18:12:12 -04:00
private:
double cur_pos[3];
uint64_t payload;
std::map< int, buzz_utility::Pos_struct> neighbours_pos_map;
int timer_step=0;
int robot_id=0;
int oldcmdID=0;
int rc_cmd;
2016-11-14 18:12:12 -04:00
std::string bzzfile_name, fcclient_name, rcservice_name,bcfname,dbgfname; //, rcclient;
bool rcclient;
ros::ServiceClient mav_client;
ros::Publisher payload_pub;
ros::ServiceServer service;
ros::Subscriber current_position_sub;
ros::Subscriber battery_sub;
ros::Subscriber payload_sub;
2016-11-18 15:05:31 -04:00
ros::Subscriber flight_status_sub;
/*Create node Handler*/
ros::NodeHandle n_c;
/*Commands for flight controller*/
mavros_msgs::CommandInt cmd_srv;
2016-11-14 18:12:12 -04:00
void Initialize_pub_sub();
/*Obtain data from ros parameter server*/
void Rosparameters_get();
2016-11-18 15:05:31 -04:00
/*compiles buzz script from the specified .bzz file*/
void Compile_bzz();
/*Prepare messages and publish*/
2016-11-18 15:05:31 -04:00
void prepare_msg_and_publish();
/*Refresh neighbours Position for every ten step*/
2016-11-18 15:05:31 -04:00
void maintain_pos(int tim_step);
/*Maintain neighbours position*/
2016-11-18 15:05:31 -04:00
void neighbours_pos_maintain(int id, buzz_utility::Pos_struct pos_arr );
/*Set the current position of the robot callback*/
2016-11-18 15:05:31 -04:00
void set_cur_pos(double latitude,
double longitude,
double altitude);
/*convert from catresian to spherical coordinate system callback */
2016-11-18 15:05:31 -04:00
double* cvt_spherical_coordinates(double neighbours_pos_payload []);
/*battery status callback*/
2016-11-18 15:05:31 -04:00
void battery(const mavros_msgs::BatteryStatus::ConstPtr& msg);
/*flight status callback*/
void flight_status_update(const mavros_msgs::ExtendedState::ConstPtr& msg);
/*current position callback*/
2016-11-18 15:05:31 -04:00
void current_pos(const sensor_msgs::NavSatFix::ConstPtr& msg);
/*payload callback callback*/
2016-11-18 15:05:31 -04:00
void payload_obt(const mavros_msgs::Mavlink::ConstPtr& msg);
/* RC commands service */
2016-11-18 15:05:31 -04:00
bool rc_callback(mavros_msgs::CommandInt::Request &req,
mavros_msgs::CommandInt::Response &res);
};
}