2016-10-10 21:22:17 -03:00
|
|
|
#pragma once
|
2017-12-08 19:52:35 -04:00
|
|
|
|
2016-10-10 21:22:17 -03:00
|
|
|
#include <buzz/buzzvm.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "mavros_msgs/CommandCode.h"
|
2017-08-09 20:23:42 -03:00
|
|
|
#include "mavros_msgs/Mavlink.h"
|
2016-10-10 21:22:17 -03:00
|
|
|
#include "ros/ros.h"
|
2017-03-14 00:08:18 -03:00
|
|
|
#include "buzz_utility.h"
|
2018-09-06 17:19:58 -03:00
|
|
|
#include "rosbuzz/mavrosCC.h"
|
2016-12-24 21:59:00 -04:00
|
|
|
|
2017-12-08 19:53:32 -04:00
|
|
|
#define EARTH_RADIUS (double)6371000.0
|
|
|
|
#define DEG2RAD(DEG) (double)((DEG) * ((M_PI) / (180.0)))
|
|
|
|
#define RAD2DEG(RAD) (double)((RAD) * ((180.0) / (M_PI)))
|
2017-05-10 08:34:57 -03:00
|
|
|
|
2017-12-08 19:53:32 -04:00
|
|
|
namespace buzzuav_closures
|
|
|
|
{
|
2016-10-10 21:22:17 -03:00
|
|
|
/*
|
|
|
|
* prextern int() function in Buzz
|
|
|
|
* This function is used to print data from buzz
|
|
|
|
* The command to use in Buzz is buzzros_print takes any available datatype in Buzz
|
|
|
|
*/
|
|
|
|
int buzzros_print(buzzvm_t vm);
|
2018-11-05 05:11:02 -04:00
|
|
|
void setWPlist(std::string file);
|
2018-11-10 04:46:27 -04:00
|
|
|
void setVorlog(std::string path);
|
2018-11-05 05:11:02 -04:00
|
|
|
void check_targets_sim(double lat, double lon, double *res);
|
2017-12-13 13:47:42 -04:00
|
|
|
|
2016-10-10 21:22:17 -03:00
|
|
|
/*
|
2017-12-13 13:47:42 -04:00
|
|
|
* closure to move following a vector
|
2016-10-10 21:22:17 -03:00
|
|
|
*/
|
2017-02-08 12:23:12 -04:00
|
|
|
int buzzuav_moveto(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* closure to store a new GPS goal
|
|
|
|
*/
|
2017-08-25 18:05:40 -03:00
|
|
|
int buzzuav_storegoal(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* closure to control the gimbal
|
|
|
|
*/
|
2017-09-08 10:53:20 -03:00
|
|
|
int buzzuav_setgimbal(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* parse a csv list of waypoints
|
|
|
|
*/
|
2017-09-06 00:48:50 -03:00
|
|
|
void parse_gpslist();
|
2017-12-19 14:09:22 -04:00
|
|
|
/*
|
|
|
|
* closure to export a 2D map
|
|
|
|
*/
|
|
|
|
int buzz_exportmap(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* closure to take a picture
|
|
|
|
*/
|
2017-09-05 01:34:59 -03:00
|
|
|
int buzzuav_takepicture(buzzvm_t vm);
|
2018-10-29 02:47:39 -03:00
|
|
|
/*
|
|
|
|
* closure to reset RC input
|
|
|
|
*/
|
|
|
|
int buzzuav_resetrc(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* Returns the current command from local variable
|
|
|
|
*/
|
2016-10-10 21:22:17 -03:00
|
|
|
int getcmd();
|
2018-10-19 03:34:18 -03:00
|
|
|
/*
|
|
|
|
* update GPS goal value
|
|
|
|
*/
|
|
|
|
void set_gpsgoal(double goal[3]);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* Sets goto position from rc client
|
|
|
|
*/
|
2017-08-18 18:13:57 -03:00
|
|
|
void rc_set_goto(int id, double latitude, double longitude, double altitude);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
*Sets gimbal orientation from rc client
|
|
|
|
*/
|
2017-09-08 10:53:20 -03:00
|
|
|
void rc_set_gimbal(int id, float yaw, float roll, float pitch, float t);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* sets rc requested command
|
|
|
|
*/
|
2016-10-10 21:22:17 -03:00
|
|
|
void rc_call(int rc_cmd);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* sets the battery state
|
|
|
|
*/
|
2017-12-08 19:53:32 -04:00
|
|
|
void set_battery(float voltage, float current, float remaining);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* sets the xbee network status
|
|
|
|
*/
|
2017-07-05 10:37:35 -03:00
|
|
|
void set_deque_full(bool state);
|
|
|
|
void set_rssi(float value);
|
|
|
|
void set_raw_packet_loss(float value);
|
|
|
|
void set_filtered_packet_loss(float value);
|
2017-12-19 14:14:56 -04:00
|
|
|
// void set_api_rssi(float value);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* sets current position
|
|
|
|
*/
|
2018-09-06 13:47:38 -03:00
|
|
|
|
|
|
|
void set_currentNEDpos(double x, double y);
|
|
|
|
|
2017-12-21 13:20:26 -04:00
|
|
|
void set_currentpos(double latitude, double longitude, float altitude, float yaw);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* returns the current go to position
|
|
|
|
*/
|
2016-10-10 21:22:17 -03:00
|
|
|
double* getgoto();
|
2017-12-20 13:20:43 -04:00
|
|
|
/*
|
|
|
|
* returns the current grid
|
|
|
|
*/
|
|
|
|
std::map<int, std::map<int,int>> getgrid();
|
2018-11-07 11:24:06 -04:00
|
|
|
int voronoi_center(buzzvm_t vm);
|
2018-09-06 13:47:38 -03:00
|
|
|
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* returns the gimbal commands
|
|
|
|
*/
|
2017-09-08 10:53:20 -03:00
|
|
|
float* getgimbal();
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
*updates flight status
|
|
|
|
*/
|
2016-11-18 15:05:31 -04:00
|
|
|
void flight_status_update(uint8_t state);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
*Update neighbors table
|
|
|
|
*/
|
2017-05-07 01:41:20 -03:00
|
|
|
void neighbour_pos_callback(int id, float range, float bearing, float elevation);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* update neighbors from in msgs
|
|
|
|
*/
|
2017-05-07 01:41:20 -03:00
|
|
|
void update_neighbors(buzzvm_t vm);
|
2018-09-06 13:47:38 -03:00
|
|
|
/*
|
|
|
|
*Clear neighbours struct
|
|
|
|
*/
|
|
|
|
void clear_neighbours_pos();
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* closure to add a neighbor status
|
|
|
|
*/
|
2017-08-09 20:23:42 -03:00
|
|
|
int buzzuav_addNeiStatus(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* returns the current array of neighbors status
|
|
|
|
*/
|
2017-08-09 20:23:42 -03:00
|
|
|
mavros_msgs::Mavlink get_status();
|
|
|
|
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
*Flight status
|
|
|
|
*/
|
2017-02-10 15:18:44 -04:00
|
|
|
void set_obstacle_dist(float dist[]);
|
|
|
|
|
2016-10-10 21:22:17 -03:00
|
|
|
/*
|
|
|
|
* Commands the UAV to takeoff
|
|
|
|
*/
|
|
|
|
int buzzuav_takeoff(buzzvm_t vm);
|
2017-03-14 00:08:18 -03:00
|
|
|
/*
|
2017-06-23 11:39:14 -03:00
|
|
|
* Arm command from Buzz
|
2017-03-14 00:08:18 -03:00
|
|
|
*/
|
2017-02-23 12:49:10 -04:00
|
|
|
int buzzuav_arm(buzzvm_t vm);
|
2017-03-14 00:08:18 -03:00
|
|
|
/*
|
|
|
|
* Disarm from buzz
|
|
|
|
*/
|
2017-12-08 19:53:32 -04:00
|
|
|
int buzzuav_disarm(buzzvm_t vm);
|
2016-10-10 21:22:17 -03:00
|
|
|
/* Commands the UAV to land
|
|
|
|
*/
|
|
|
|
int buzzuav_land(buzzvm_t vm);
|
|
|
|
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* Command the UAV to go to home location
|
2016-10-10 21:22:17 -03:00
|
|
|
*/
|
|
|
|
int buzzuav_gohome(buzzvm_t vm);
|
2018-11-09 15:25:58 -04:00
|
|
|
int buzzuav_geofence(buzzvm_t vm);
|
2016-10-10 21:22:17 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Updates battery information in Buzz
|
|
|
|
*/
|
|
|
|
int buzzuav_update_battery(buzzvm_t vm);
|
2017-07-06 15:50:29 -03:00
|
|
|
/*
|
|
|
|
* Updates xbee_status information in Buzz
|
|
|
|
*/
|
|
|
|
int buzzuav_update_xbee_status(buzzvm_t vm);
|
2016-11-18 15:05:31 -04:00
|
|
|
/*
|
|
|
|
* Updates current position in Buzz
|
|
|
|
*/
|
|
|
|
int buzzuav_update_currentpos(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* add new target in the BVM
|
|
|
|
*/
|
2017-06-26 15:09:33 -03:00
|
|
|
int buzzuav_addtargetRB(buzzvm_t vm);
|
2016-11-18 15:05:31 -04:00
|
|
|
/*
|
2017-06-23 11:39:14 -03:00
|
|
|
* Updates flight status and rc command in Buzz, put it in a tabel to acess it
|
2016-12-02 20:11:36 -04:00
|
|
|
* use flight.status for flight status
|
|
|
|
* use flight.rc_cmd for current rc cmd
|
2016-11-18 15:05:31 -04:00
|
|
|
*/
|
|
|
|
int buzzuav_update_flight_status(buzzvm_t vm);
|
2016-10-10 21:22:17 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Updates IR information in Buzz
|
|
|
|
* Proximity and ground sensors to do !!!!
|
|
|
|
*/
|
|
|
|
int buzzuav_update_prox(buzzvm_t vm);
|
2017-12-13 13:47:42 -04:00
|
|
|
/*
|
|
|
|
* returns the current FC command
|
|
|
|
*/
|
2016-12-24 21:59:00 -04:00
|
|
|
int bzz_cmd();
|
|
|
|
|
2017-01-08 14:17:13 -04:00
|
|
|
int dummy_closure(buzzvm_t vm);
|
2016-10-10 21:22:17 -03:00
|
|
|
}
|