Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • authierj/dfall-system
1 result
Show changes
Showing
with 2320 additions and 8 deletions
dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/images/flying_state_off.png

3.03 KiB

dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/images/rf_connected.png

6.26 KiB

dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/images/rf_connecting.png

5.55 KiB

dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/images/rf_disconnected.png

5.2 KiB

// Copyright (C) 2017, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// Constants that are used across multiple files
//
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
// U U
// U U
// U U
// U U
// UUU
// ----------------------------------------------------------------------------------
// Conversions between degrees and radians
#define RAD2DEG 180.0/PI
#define DEG2RAD PI/180.0
// PI
#define PI 3.141592653589
// ----------------------------------------------------------------------------------
//
//
//
//
//
// ----------------------------------------------------------------------------------
// The types, i.e., agent or coordinator
#define TYPE_INVALID -1
#define TYPE_COORDINATOR 1
#define TYPE_AGENT 2
// ----------------------------------------------------------------------------------
//
//
//
//
//
// ----------------------------------------------------------------------------------
// These constants define the modes that can be used for controller this is
// running on-board the Crazyflie 2.0.
// Therefore, the constants defined here need to be in agreement with those
// defined in the firmware running on-board the Crazyflie 2.0.
// The following is a short description about each mode:
//
// CF_COMMAND_TYPE_MOTORS
// In this mode the Crazyflie will apply the requested 16-bit per motor
// command directly to each of the motors
//
// CF_COMMAND_TYPE_RATE
// In this mode the Crazyflie will apply the requested 16-bit per motor
// command directly to each of the motors, and additionally request the
// body frame roll, pitch, and yaw angular rates from the PID rate
// controllers implemented in the Crazyflie 2.0 firmware.
//
// CF_COMMAND_TYPE_ANGLE
// In this mode the Crazyflie will apply the requested 16-bit per motor
// command directly to each of the motors, and additionally request the
// body frame roll, pitch, and yaw angles from the PID attitude
// controllers implemented in the Crazyflie 2.0 firmware.
#define CF_COMMAND_TYPE_MOTORS 6
#define CF_COMMAND_TYPE_RATE 7
#define CF_COMMAND_TYPE_ANGLE 8
// Types of controllers being used:
#define DEFAULT_CONTROLLER 1
#define DEMO_CONTROLLER 2
#define STUDENT_CONTROLLER 3
#define MPC_CONTROLLER 4
#define REMOTE_CONTROLLER 5
#define TUNING_CONTROLLER 6
#define PICKER_CONTROLLER 7
#define TEMPLATE_CONTROLLER 8
#define CSONE_CONTROLLER 9
#define TUTORIAL_CONTROLLER 10
#define TESTMOTORS_CONTROLLER 21
// The constants that "command" changes in the
// operation state of this agent
#define CMD_USE_DEFAULT_CONTROLLER 1
#define CMD_USE_DEMO_CONTROLLER 2
#define CMD_USE_STUDENT_CONTROLLER 3
#define CMD_USE_MPC_CONTROLLER 4
#define CMD_USE_REMOTE_CONTROLLER 5
#define CMD_USE_TUNING_CONTROLLER 6
#define CMD_USE_PICKER_CONTROLLER 7
#define CMD_USE_TEMPLATE_CONTROLLER 8
#define CMD_USE_CSONE_CONTROLLER 9
#define CMD_USE_TUTORIAL_CONTROLLER 10
#define CMD_CRAZYFLY_TAKE_OFF 11
#define CMD_CRAZYFLY_LAND 12
#define CMD_CRAZYFLY_MOTORS_OFF 13
#define CMD_USE_TESTMOTORS_CONTROLLER 21
// Flying states
#define STATE_MOTORS_OFF 1
#define STATE_TAKE_OFF 2
#define STATE_FLYING 3
#define STATE_LAND 4
#define STATE_UNAVAILABLE 5
// Commands for CrazyRadio
#define CMD_RECONNECT 0
#define CMD_DISCONNECT 1
// CrazyRadio states:
#define CRAZY_RADIO_STATE_CONNECTED 0
#define CRAZY_RADIO_STATE_CONNECTING 1
#define CRAZY_RADIO_STATE_DISCONNECTED 2
// ----------------------------------------------------------------------------------
// BBBB A TTTTT TTTTT EEEEE RRRR Y Y
// B B A A T T E R R Y Y
// BBBB A A T T EEE RRRR Y
// B B AAAAA T T E R R Y
// BBBB A A T T EEEEE R R Y
// ----------------------------------------------------------------------------------
// Battery levels
#define BATTERY_LEVEL_000 0
#define BATTERY_LEVEL_010 1
#define BATTERY_LEVEL_020 2
#define BATTERY_LEVEL_030 3
#define BATTERY_LEVEL_040 4
#define BATTERY_LEVEL_050 5
#define BATTERY_LEVEL_060 6
#define BATTERY_LEVEL_070 7
#define BATTERY_LEVEL_080 8
#define BATTERY_LEVEL_090 9
#define BATTERY_LEVEL_100 10
#define BATTERY_LEVEL_UNAVAILABLE -1
// Battery states
#define BATTERY_STATE_NORMAL 0
#define BATTERY_STATE_LOW 1
// ----------------------------------------------------------------------------------
// Y Y A M M L
// Y Y A A MM MM L
// Y A A M M M L
// Y AAAAA M M L
// Y A A M M LLLLL
// ----------------------------------------------------------------------------------
// For where to load the yaml file from
#define LOAD_YAML_FROM_AGENT 1
#define LOAD_YAML_FROM_COORDINATOR 2
// ----------------------------------------------------------------------------------
//
//
//
//
//
// ----------------------------------------------------------------------------------
// These constants deine the current and interaction with an intergrator
#define INTEGRATOR_FLAG_ON 1
#define INTEGRATOR_FLAG_OFF 2
#define INTEGRATOR_FLAG_UNKNOWN 3
#define INTEGRATOR_FLAG_TOGGLE 4
#define INTEGRATOR_FLAG_RESET 5
// ----------------------------------------------------------------------------------
//
//
//
//
//
// ----------------------------------------------------------------------------------
// For standard buttons in the GUI
#define REQUEST_DEFAULT_SETPOINT_BUTTON_ID 100
// Copyright (C) 2017, ETH Zurich, D-ITET, Cyrill Burgener, Marco Mueller, Philipp Friedli
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
......@@ -25,16 +25,32 @@
//
//
// DESCRIPTION:
// Header for the service that manages the context of the student groups.
// Constants that are used across the Picker Controler Service and GUI
//
// ----------------------------------------------------------------------------------
//for field command in CMCommand
#define CMD_SAVE 1
#define CMD_RELOAD 2
//for field mode in CMUpdate
#define ENTRY_INSERT_OR_UPDATE 1
#define ENTRY_REMOVE 2
// TO IDENITFY THE STATE OF THE PICKER
#define PICKER_STATE_UNKNOWN -1
#define PICKER_STATE_STANDBY 0
#define PICKER_STATE_GOTO_START 1
#define PICKER_STATE_ATTACH 2
#define PICKER_STATE_LIFT_UP 3
#define PICKER_STATE_GOTO_END 4
#define PICKER_STATE_PUT_DOWN 5
#define PICKER_STATE_SQUAT 6
#define PICKER_STATE_JUMP 7
// DEFAULT {x,y,z,yaw,mass}
#define PICKER_DEFAULT_X 0
#define PICKER_DEFAULT_Y 0
#define PICKER_DEFAULT_Z 0.4
#define PICKER_DEFAULT_YAW_DEGREES 0
#define PICKER_DEFAULT_MASS_GRAMS 30
\ No newline at end of file
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The bar of the GUI for (dis-)connecting (from)to the Crazyradio
// and for sending the {take-off,land,motors-off} commands//
//
// ----------------------------------------------------------------------------------
#ifndef CONNECTSTARTSTOPBAR_H
#define CONNECTSTARTSTOPBAR_H
#include <string>
#include <QWidget>
#include <QMutex>
#include <QTextStream>
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
// Include the standard message types
#include "std_msgs/Int32.h"
#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
// Include the DFALL message types
#include "dfall_pkg/IntWithHeader.h"
#include "dfall_pkg/AreaBounds.h"
#include "dfall_pkg/CrazyflieContext.h"
#include "dfall_pkg/IntIntService.h"
#include "dfall_pkg/CMQuery.h"
// Include the shared definitions
#include "nodes/Constants.h"
// SPECIFY THE PACKAGE NAMESPACE
//using namespace dfall_pkg;
#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"
#endif
// BATTERY LABEL IMAGE INDEX
#define BATTERY_LABEL_IMAGE_INDEX_UNVAILABLE -1
#define BATTERY_LABEL_IMAGE_INDEX_EMPTY 0
#define BATTERY_LABEL_IMAGE_INDEX_20 1
#define BATTERY_LABEL_IMAGE_INDEX_40 2
#define BATTERY_LABEL_IMAGE_INDEX_60 3
#define BATTERY_LABEL_IMAGE_INDEX_80 4
#define BATTERY_LABEL_IMAGE_INDEX_FULL 5
#define BATTERY_LABEL_IMAGE_INDEX_UNKNOWN 6
namespace Ui {
class ConnectStartStopBar;
}
class ConnectStartStopBar : public QWidget
{
Q_OBJECT
public:
explicit ConnectStartStopBar(QWidget *parent = 0);
~ConnectStartStopBar();
public slots:
void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);
private:
// --------------------------------------------------- //
// PRIVATE VARIABLES
Ui::ConnectStartStopBar *ui;
// > For the type of this node,
// i.e., an agent or a coordinator
int m_type = 0;
// > For the ID of this node
int m_ID = 0;
// For coordinating multiple agents
std::vector<int> m_vector_of_agentIDs_toCoordinate;
bool m_shouldCoordinateAll = true;
QMutex m_agentIDs_toCoordinate_mutex;
// > For keeping track of the current battery state
int m_battery_state;
// > For keeping track of which image is currently displayed
int m_battery_status_label_image_current_index;
// MUTEX FOR HANDLING ACCESS
// > For the "rf_status_label" UI element
//QMutex m_rf_status_label_mutex;
// > For the "battery_voltage_lineEdit" UI element
//QMutex m_battery_voltage_lineEdit_mutex;
// > For the "battery_status_label" UI element
QMutex m_battery_status_label_mutex;
// --------------------------------------------------- //
// PRIVATE FUNCTIONS
// > For making the "enable flight" and "disable flight"
// buttons (un-)available
void disableFlyingStateButtons();
void enableFlyingStateButtons();
// > For updating the RF Radio status shown in the UI element
// of "rf_status_label"
void setCrazyRadioStatus(int radio_status);
// > For updating the battery state
void setBatteryState(int new_battery_state);
// > For updating the battery voltage shown in the UI elements
// of "battery_voltage_lineEdit" and "battery_status_label"
void setBatteryVoltageText(float battery_voltage);
void setBatteryImageBasedOnLevel(int battery_level);
// > For updating the "my_flying_state" variable, and the
// UI element of "flying_state_label"
void setFlyingState(int new_flying_state);
#ifdef CATKIN_MAKE
// --------------------------------------------------- //
// PRIVATE VARIABLES FOR ROS
// PUBLISHERS AND SUBSRIBERS
// > For Crazyradio commands based on button clicks
ros::Publisher crazyRadioCommandPublisher;
// > For updating the "rf_status_label" picture
ros::Subscriber crazyRadioStatusSubscriber;
// > For updating the current battery voltage
ros::Subscriber batteryVoltageSubscriber;
// > For updating the current battery state
//ros::Subscriber batteryStateSubscriber;
// > For updating the current battery level
ros::Subscriber batteryLevelSubscriber;
// > For Flying state commands based on button clicks
ros::Publisher flyingStateCommandPublisher;
// > For updating the "flying_state_label" picture
ros::Subscriber flyingStateSubscriber;
// --------------------------------------------------- //
// PRIVATE CALLBACKS IN RESPONSE TO ROS MESSAGES
// Get the type and ID of this node
bool getTypeAndIDParameters();
// Fill the head for a message
void fillIntMessageHeader( dfall_pkg::IntWithHeader & msg );
// > For the CrazyRadio status, received on the
// "crazyRadioStatusSubscriber"
void crazyRadioStatusCallback(const std_msgs::Int32& msg);
// > For the Battery Voltage, received on the
// "batteryVoltageSubscriber"
void batteryVoltageCallback(const std_msgs::Float32& msg);
// > For the Battery State, receieved on the
// "batteryStateSubscriber"
void batteryStateChangedCallback(const std_msgs::Int32& msg);
// > For the Battery Level, receieved on the
// "batteryLevelSubscriber"
void batteryLevelCallback(const std_msgs::Int32& msg);
// > For the Flying State, received on the
// "flyingStateSubscriber"
void flyingStateChangedCallback(const std_msgs::Int32& msg);
#endif
private slots:
// PRIVATE METHODS FOR BUTTON CALLBACKS
// > For the RF Crazyradio connect/disconnect buttons
void on_rf_connect_button_clicked();
void on_rf_disconnect_button_clicked();
// > For the enable, disable, motors-off buttons
void on_enable_flying_button_clicked();
void on_disable_flying_button_clicked();
void on_motors_off_button_clicked();
};
#endif // CONNECTSTARTSTOPBAR_H
// Copyright (C) 2020, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// A banner that indicates the status of a controller.
// Possible status values are: { OFF , ACTIVE , COORD }
//
// ----------------------------------------------------------------------------------
#ifndef CONTROLLERSTATUSBANNER_H
#define CONTROLLERSTATUSBANNER_H
#include <QWidget>
#include <QMutex>
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
#else
#include <QTextStream>
#endif
// STATUS VALUES
#define CONTROLLER_STATUS_BANNER_OFF 0
#define CONTROLLER_STATUS_BANNER_ACTIVE 1
#define CONTROLLER_STATUS_BANNER_COORD 2
namespace Ui {
class ControllerStatusBanner;
}
class ControllerStatusBanner : public QWidget
{
Q_OBJECT
public:
explicit ControllerStatusBanner(QWidget *parent = 0);
~ControllerStatusBanner();
// PUBLIC METHODS FOR SETTING PROPERTIES
// > Set the state of the checkbox
void setStatus(int new_status);
private:
// --------------------------------------------------- //
// PRIVATE VARIABLES
Ui::ControllerStatusBanner *ui;
// > For the current status
int m_current_status;
// MUTEX FOR HANDLING ACCESS
// > For the status variable and UI elements
QMutex m_status_mutex;
};
#endif // CONTROLLERSTATUSBANNER_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The tab wdiget that contains and manages the individual tabs used
// to interface with each separate controller.
//
// ----------------------------------------------------------------------------------
#ifndef CONTROLLERTABS_H
#define CONTROLLERTABS_H
#include "controllerstatusbanner.h"
#include <QWidget>
#include <QMutex>
#include <QVector>
//#include <QSoundEffect>
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
// Include the standard message types
#include "std_msgs/Int32.h"
//#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
// Include the DFALL message types
//#include "dfall_pkg/IntWithHeader.h"
//#include "dfall_pkg/SetpointWithHeader.h"
#include "dfall_pkg/FlyingVehicleState.h"
#include "dfall_pkg/ViconData.h"
#include "dfall_pkg/AreaBounds.h"
#include "dfall_pkg/CrazyflieContext.h"
#include "dfall_pkg/CMQuery.h"
// Include the DFALL service types
#include "dfall_pkg/IntIntService.h"
// Include the shared definitions
//#include "nodes/Constants.h"
// SPECIFY THE PACKAGE NAMESPACE
//using namespace dfall_pkg;
#else
// Include the shared definitions
//#include "include/Constants_for_Qt_compile.h"
#endif
namespace Ui {
class ControllerTabs;
}
class ControllerTabs : public QWidget
{
Q_OBJECT
public:
explicit ControllerTabs(QWidget *parent = 0);
~ControllerTabs();
// PUBLIC METHODS FOR TOGGLING THE VISISBLE CONTROLLERS
void showHideController_toggle(QString qstr_label, QWidget * tab_widget_to_toggle);
void showHideController_default_changed();
void showHideController_student_changed();
void showHideController_picker_changed();
void showHideController_tuning_changed();
void showHideController_remote_changed();
void showHideController_template_changed();
void showHideController_csone_changed();
void showHideController_tutorial_changed();
public slots:
void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);
void setObjectNameForDisplayingPoseData( QString object_name );
signals:
void agentIDsToCoordinateChanged(QVector<int> agentIDs , bool shouldCoordinateAll);
void measuredPoseValueChanged(float x , float y , float z , float roll , float pitch , float yaw , bool isValid);
void poseDataUnavailableSignal();
private:
Ui::ControllerTabs *ui;
// --------------------------------------------------- //
// PRIVATE VARIABLES
// The type of this node, i.e., agent or a coordinator,
// specified as a parameter in the "*.launch" file
int m_type = 0;
// The ID of this node
int m_ID;
// For coordinating multiple agents
std::vector<int> m_vector_of_agentIDs_toCoordinate;
bool m_shouldCoordinateAll = true;
QMutex m_agentIDs_toCoordinate_mutex;
// The object name for which motion capture pose data
// will be "emitted" using the "measuredPoseValueChanged"
// signal
std::string m_object_name_for_emitting_pose_data;
// Flag for whether pose data should be emitted, this is
// to save looking through the data when it is unnecessary
bool m_should_search_pose_data_for_object_name = false;
QMutex m_should_search_pose_data_for_object_name_mutex;
// Mutex for the highlighting of the active controller
QMutex m_change_highlighted_controller_mutex;
// Sound effect for when the controller changes while flying
//QSoundEffect m_soundEffect_controllerChanged;
// FLAG FOR WHAT DATA TO EMIT
// > For "poseDataMocap"
bool m_shouldEmitPoseDataMocap = true;
// > For "poseDataOnboard"
bool m_shouldEmitPoseDataOnboard = false;
#ifdef CATKIN_MAKE
// --------------------------------------------------- //
// PRIVATE VARIABLES FOR ROS
// > For the "context" of this agent
dfall_pkg::CrazyflieContext m_context;
dfall_pkg::AreaBounds m_area;
// SUBSRIBER
// > For the pose data from a motion capture system
ros::Subscriber m_poseDataMocapSubscriber;
// > For the pose data from a onboard state estimate
ros::Subscriber m_poseDataOnboardSubscriber;
// > For the controller that is currently operating
ros::Subscriber controllerUsedSubscriber;
// > For changes in the database that defines {agentID,cfID,flying zone} links
//ros::Subscriber databaseChangedSubscriber;
ros::ServiceClient centralManagerDatabaseService;
#endif
#ifdef CATKIN_MAKE
// --------------------------------------------------- //
// PRIVATE CALLBACKS IN RESPONSE TO ROS MESSAGES
// > For the data from the motion capture system, received on
// "m_poseDataMocapSubscriber"
void poseDataMocapReceivedCallback(const dfall_pkg::ViconData& viconData);
// > For the data from onboard the flying agent, received on
// "m_poseDataOnboardSubscriber"
void poseDataOnboardReceivedCallback(const dfall_pkg::FlyingVehicleState& vehicleState);
// > For the controller currently operating, received on
// "controllerUsedSubscriber"
void controllerUsedChangedCallback(const std_msgs::Int32& msg);
// Get the paramters that specify the type and ID
bool getTypeAndIDParameters();
#endif
void setControllerEnabled(int new_controller);
void setTextColourOfTabLabel(QColor color , QWidget * tab_widget);
void setAllTabLabelsToNormalColouring();
void setAllBannersToControllerIsOff();
void setAllBannersToControllerCoordinator();
};
#endif // CONTROLLERTABS_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The coordinator part of the Flying Agent GUI that allows multiple
// flying agents to be controller from one place, and keeps track
// of which subset of flying agents to control.
//
// ----------------------------------------------------------------------------------
#ifndef COORDINATOR_H
#define COORDINATOR_H
#include "coordinatorrow.h"
#include <QWidget>
#include <QVector>
#include <regex>
#include <QTextStream>
namespace Ui {
class Coordinator;
}
class Coordinator : public QWidget
{
Q_OBJECT
public:
explicit Coordinator(QWidget *parent = 0);
~Coordinator();
public slots:
void setShouldCoordinateThisAgent(int agentID , bool shouldCoordinate);
signals:
void agentIDsToCoordinateChanged(QVector<int> agentIDs , bool shouldCoordinateAll);
private:
QVector<CoordinatorRow*> vector_of_coordinatorRows;
QVector<bool> vector_of_shouldCoordinate_perRow;
QVector<int> vector_of_agentID_perRow;
int level_of_detail_to_display = 1;
void remove_all_entries_from_vector_of_coordinatorRows();
void apply_level_of_detail_to_all_entries(int level);
private slots:
void on_refresh_button_clicked();
void on_toggle_details_button_clicked();
void on_delete_button_clicked();
void on_coordinate_all_checkBox_clicked();
void emit_signal_with_agentIDs_toCoordinate();
private:
Ui::Coordinator *ui;
};
#endif // COORDINATOR_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// An individual row in the coordinator part of the Flying Agent
// GUI. This is essentially a condensed version of the
// "Connect Start Stop Bar"
//
// ----------------------------------------------------------------------------------
#ifndef COORDINATORROW_H
#define COORDINATORROW_H
#include <string>
#include <QWidget>
#include <QMutex>
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
// Include the standard message types
#include "std_msgs/Int32.h"
#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
// Include the DFALL message types
#include "dfall_pkg/IntWithHeader.h"
#include "dfall_pkg/AreaBounds.h"
#include "dfall_pkg/CrazyflieContext.h"
#include "dfall_pkg/CMQuery.h"
#include "dfall_pkg/IntIntService.h"
// Include the shared definitions
#include "nodes/Constants.h"
// SPECIFY THE PACKAGE NAMESPACE
//using namespace dfall_pkg;
#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"
#endif
// BATTERY LABEL IMAGE INDEX
#define BATTERY_LABEL_IMAGE_INDEX_UNVAILABLE -1
#define BATTERY_LABEL_IMAGE_INDEX_EMPTY 0
#define BATTERY_LABEL_IMAGE_INDEX_20 1
#define BATTERY_LABEL_IMAGE_INDEX_40 2
#define BATTERY_LABEL_IMAGE_INDEX_60 3
#define BATTERY_LABEL_IMAGE_INDEX_80 4
#define BATTERY_LABEL_IMAGE_INDEX_FULL 5
#define BATTERY_LABEL_IMAGE_INDEX_UNKNOWN 6
namespace Ui {
class CoordinatorRow;
}
class CoordinatorRow : public QWidget
{
Q_OBJECT
public:
explicit CoordinatorRow(QWidget *parent = 0, int agentID = 0);
~CoordinatorRow();
// PUBLIC METHODS FOR SETTING PROPERTIES
// > Set the state of the checkbox
void setShouldCoordinate(bool shouldCoordinate);
// > Set the level of detail to display
void setLevelOfDetailToDisplay(int level);
signals:
void shouldCoordinateThisAgentValueChanged(int agentID , bool shouldCoordinate);
private:
// --------------------------------------------------- //
// PRIVATE VARIABLES
Ui::CoordinatorRow *ui;
// > For the ID of which agent this "coordinator row" relates to
int m_agentID;
// > For using the agent ID in constructing namespaces
QString m_agentID_as_string;
// > For the name of the allocated Crazyflie
QString m_crazyflie_name_as_string;
// > For keeping track of the current battery state
int m_battery_state;
// > For keeping track of which image is currently displayed
int m_battery_status_label_image_current_index;
// MUTEX FOR HANDLING ACCESS
// > For the "rf_status_label" UI element
//QMutex m_rf_status_label_mutex;
// > For the "battery_voltage_lineEdit" UI element
//QMutex m_battery_voltage_lineEdit_mutex;
// > For the "battery_status_label" UI element
QMutex m_battery_status_label_mutex;
// --------------------------------------------------- //
// PRIVATE FUNCTIONS
// > For making the "enable flight" and "disable flight" buttons
// (un-)available
void disableFlyingStateButtons();
void enableFlyingStateButtons();
// > For updating the RF Radio status shown in the UI element
// of "rf_status_label"
void setCrazyRadioStatus(int radio_status);
// > For updating the battery state
void setBatteryState(int new_battery_state);
// > For updating the battery voltage shown in the UI elements
// of "battery_voltage_lineEdit" and "battery_status_label"
void setBatteryVoltageText(float battery_voltage);
void setBatteryImageBasedOnLevel(int battery_level);
// > For updating the "my_flying_state" variable, and the
// UI element of "flying_state_label"
void setFlyingState(int new_flying_state);
// > For loading the "context" for this agent,
// i.e., the {agentID,cfID,flying zone} tuple
void loadCrazyflieContext();
// > For requesting the current flying state
// i.e., using the service advertised by the Flying Agent Client
void getCurrentFlyingState();
// > For requesting the current state of the Crazy Radio
// i.e., using the service advertised by the Flying Agent Client
void getCurrentCrazyRadioState();
// > For updating the text in the UI element of
// "controller_enabled_label"
void setControllerEnabled(int new_controller);
#ifdef CATKIN_MAKE
// --------------------------------------------------- //
// PRIVATE VARIABLES FOR ROS
// > For the "context" of this agent
dfall_pkg::CrazyflieContext my_context;
// PUBLISHERS AND SUBSRIBERS
// > For Crazyradio commands based on button clicks
ros::Publisher crazyRadioCommandPublisher;
// > For updating the "rf_status_label" picture
ros::Subscriber crazyRadioStatusSubscriber;
// > For updating the current battery voltage
ros::Subscriber batteryVoltageSubscriber;
// > For updating the current battery state
//ros::Subscriber batteryStateSubscriber;
// > For updating the current battery level
ros::Subscriber batteryLevelSubscriber;
// > For Flying state commands based on button clicks
ros::Publisher flyingStateCommandPublisher;
// > For updating the "flying_state_label" picture
ros::Subscriber flyingStateSubscriber;
// > For changes in the database that defines {agentID,cfID,flying zone} links
ros::Subscriber databaseChangedSubscriber;
ros::ServiceClient centralManagerDatabaseService;
// > For updating the controller that is currently operating
ros::Subscriber controllerUsedSubscriber;
// > For requesting the current flying state,
// this is used only for initialising the icon
ros::ServiceClient getCurrentFlyingStateService;
// > For requesting the current state of the Crazy Radio,
// this is used only for initialising the icon
ros::ServiceClient getCurrentCrazyRadioStateService;
// --------------------------------------------------- //
// PRIVATE CALLBACKS IN RESPONSE TO ROS MESSAGES
// > For the CrazyRadio status, received on the
// "crazyRadioStatusSubscriber"
void crazyRadioStatusCallback(const std_msgs::Int32& msg);
// > For the Battery Voltage, received on the
// "batteryVoltageSubscriber"
void batteryVoltageCallback(const std_msgs::Float32& msg);
// > For the Battery State, receieved on the
// "batteryStateSubscriber"
void batteryStateChangedCallback(const std_msgs::Int32& msg);
// > For the Battery Level, receieved on the
// "batteryLevelSubscriber"
void batteryLevelCallback(const std_msgs::Int32& msg);
// > For the Flying State, received on the
// "flyingStateSubscriber"
void flyingStateChangedCallback(const std_msgs::Int32& msg);
// > For the notification that the database was changes,
// received on the "DatabaseChangedSubscriber"
void databaseChangedCallback(const std_msgs::Int32& msg);
// > For the controller currently operating, received on
// "controllerUsedSubscriber"
void controllerUsedChangedCallback(const std_msgs::Int32& msg);
#endif
private slots:
// PRIVATE METHODS FOR BUTTON CALLBACKS
// > For the RF Crazyradio connect/disconnect buttons
void on_rf_connect_button_clicked();
void on_rf_disconnect_button_clicked();
// > For the enable, disable, motors-off buttons
void on_enable_flying_button_clicked();
void on_disable_flying_button_clicked();
void on_motors_off_button_clicked();
// > For the "should coordinate" checkbox
void on_shouldCoordinate_checkBox_clicked();
};
#endif // COORDINATORROW_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The GUI for a Csone Controller for students build from
//
// ----------------------------------------------------------------------------------
// NOTE: Instructions for how to add a Chart are taken from this stack overflow answer:
// https://stackoverflow.com/questions/48362864/how-to-insert-qchartview-in-form-with-qt-designer
//
// Option 1: Promoted
// 1) first add QT += charts in the .pro
// 2) place the QGraphicsView to the design.
// 3) Right click on the QGraphicsView and select Promote to...
// 4) When doing the above, a menu appears, in the menu it should be set in QChartView in Promoted
// Class Name, and QtCharts in Header file, then press the add button and finally press promote.
//
// Option 2: QtChart plugin
// This option was NOT used, see answer on stack overflow for further details
#ifndef CSONECONTROLLERTAB_H
#define CSONECONTROLLERTAB_H
#include <QWidget>
#include <QMutex>
#include <QVector>
#include <QLineEdit>
#include <QTextStream>
// For the chart:
#include <QChart>
#include <QLineSeries>
#include <QList>
#include <QPointF>
using namespace QtCharts;
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
// Include the standard message types
//#include "std_msgs/Int32.h"
//#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
// Include the DFALL message types
#include "dfall_pkg/IntWithHeader.h"
#include "dfall_pkg/SetpointWithHeader.h"
#include "dfall_pkg/CustomButtonWithHeader.h"
// Include the DFALL service types
#include "dfall_pkg/IntIntService.h"
#include "dfall_pkg/GetSetpointService.h"
// Include the shared definitions
#include "nodes/Constants.h"
// SPECIFY THE PACKAGE NAMESPACE
//using namespace dfall_pkg;
#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"
#endif
namespace Ui {
class CsoneControllerTab;
}
class CsoneControllerTab : public QWidget
{
Q_OBJECT
public:
explicit CsoneControllerTab(QWidget *parent = 0);
~CsoneControllerTab();
public slots:
void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);
void setMeasuredPose(float x , float y , float z , float roll , float pitch , float yaw , bool isValid);
void poseDataUnavailableSlot();
private slots:
float validate_and_get_value_from_lineEdit(QLineEdit * lineEdit, float min, float max, int decimals, float default_value);
void newDataForPerformingStepAndPlotting(float x, float pitch);
void analyseStepResponse();
void updateStepAnalysisLineEdit(float value, QLineEdit * lineEdit, int num_dec_places);
void on_perform_step_button_clicked();
void on_log_data_button_clicked();
void on_simulate_step_response_button_clicked();
void on_clear_simulation_button_clicked();
void on_set_lead_compensator_parameters_button_clicked();
void on_set_lag_compensator_parameters_button_clicked();
void on_set_time_delay_button_clicked();
void on_set_pitch_error_button_clicked();
void on_toggle_integrator_button_clicked();
void on_reset_integrator_button_clicked();
void on_lineEdit_k_returnPressed();
void on_lineEdit_T_returnPressed();
void on_lineEdit_alpha_returnPressed();
void on_lineEdit_T_lag_returnPressed();
void on_lineEdit_alpha_lag_returnPressed();
void on_lineEdit_kp_returnPressed();
void on_lineEdit_kd_returnPressed();
void on_lineEdit_time_delay_returnPressed();
void on_lineEdit_pitch_error_returnPressed();
void on_lineEdit_step_size_returnPressed();
void on_lineEdit_step_duration_returnPressed();
void on_lineEdit_k_editingFinished();
void on_lineEdit_T_editingFinished();
void on_lineEdit_alpha_editingFinished();
void on_lineEdit_T_lag_editingFinished();
void on_lineEdit_alpha_lag_editingFinished();
void on_lineEdit_step_size_editingFinished();
void on_lineEdit_step_duration_editingFinished();
void simulate_step_response();
private:
Ui::CsoneControllerTab *ui;
// --------------------------------------------------- //
// PRIVATE VARIABLES
// The type of this node, i.e., agent or a coordinator,
// specified as a parameter in the "*.launch" file
int m_type = 0;
// The ID of this node
int m_ID;
// For coordinating multiple agents
std::vector<int> m_vector_of_agentIDs_toCoordinate;
bool m_shouldCoordinateAll = true;
QMutex m_agentIDs_toCoordinate_mutex;
// For the current setpoints
float m_current_setpoint_x = 0.0;
float m_current_setpoint_y = 0.0;
float m_current_setpoint_z = 0.4;
float m_current_setpoint_yaw = 0.0;
// > Mutex for serialising acess to the controller variables
QMutex m_controller_parameter_mutex;
// > Mutex for serialising acess to the lag controller variables
QMutex m_lag_controller_parameter_mutex;
// FOR PLOTTING DATA ON THE CHART
// > Mutex for serialising acess to any charting variable
QMutex m_chart_mutex;
// > Flag for whether to perform a step
bool m_shouldPerformStep = false;
// > Flag for whether to store data for plotting
bool m_shouldStoreData_for_plotting = false;
// > Flag for reseting the zoom level
bool m_shouldResetZoom = false;
// > Time (as a float) for the horizontal axis
float m_time_for_step = 0.0f;
// > The duration for which to record the step
float m_step_response_data_recording_duration = 20.0f;
// > Line Series for the x position data
QLineSeries *m_lineSeries_for_setpoint_x;
QLineSeries *m_lineSeries_for_measured_x;
// > Line Series for the pitch angle data
//QLineSeries *m_lineSeries_for_setpoint_pitch;
QLineSeries *m_lineSeries_for_measured_pitch;
// FOR SIMULATING THE CONTROLLER
// > Mutex for serialising acess to any simulation variables
QMutex m_simulation_mutex;
// Flag for whether a simulation is under way
bool m_simulationIsInProgress = false;
// The state space matrices of lead compensator controller
float m_lead_compensator_A=0.987578;
float m_lead_compensator_B=0.00496888;
float m_lead_compensator_C=-0.36;
float m_lead_compensator_D=0.16;
// The state of lead compensator controller
float m_lead_compensator_state = 0.0;
// The state space matrices of lag compensator controller
float m_lag_compensator_A=0.0;
float m_lag_compensator_B=0.0;
float m_lag_compensator_C=0.0;
float m_lag_compensator_D=1.0;
// The state of lead compensator controller
float m_lag_compensator_state = 0.0;
// Line Series for plotting the simulation results
QLineSeries *m_lineSeries_for_sim_setpoint_x;
QLineSeries *m_lineSeries_for_sim_measured_x;
QLineSeries *m_lineSeries_for_sim_measured_pitch;
#ifdef CATKIN_MAKE
// PUBLISHER
// > For requesting the setpoint to be changed
ros::Publisher requestSetpointChangePublisher;
// > For requesting the controller parameters to be changed
ros::Publisher requestControllerParameterChangePublisher;
// > For requesting the lag controller parameters to be changed
ros::Publisher requestLagControllerParameterChangePublisher;
// > For requesting a change in the integrator state
ros::Publisher requestIntegratorStateChangePublisher;
// > For requesting the time delay to be changed
ros::Publisher requestTimeDelayChangePublisher;
// > For requesting the pitch error to be changed
ros::Publisher requestPitchErrorChangePublisher;
// SUBSCRIBER
// > For being notified when the setpoint is changed
ros::Subscriber setpointChangedSubscriber;
// > For being notified when the integrator state
ros::Subscriber integratorStateChangedSubscriber;
// PUBLISHER
// > For notifying that a custom button is pressed
ros::Publisher customButtonPublisher;
#endif
// --------------------------------------------------- //
// PRIVATE FUNCTIONS
#ifdef CATKIN_MAKE
// For receiving message that the setpoint was changed
void setpointChangedCallback(const dfall_pkg::SetpointWithHeader& newSetpoint);
// For receiving message that the integrator state changes
void integratorStateChangedCallback(const dfall_pkg::IntWithHeader& newIntegratorState);
// Fill the header for a message
void fillIntMessageHeader( dfall_pkg::IntWithHeader & msg );
void fillSetpointMessageHeader( dfall_pkg::SetpointWithHeader & msg );
void fillCustomButtonMessageHeader( dfall_pkg::CustomButtonWithHeader & msg );
// Get the paramters that specify the type and ID
bool getTypeAndIDParameters();
#endif
void publishSetpoint(float x, float y, float z, float yaw_degrees);
void publishControllerParameters(float k, float T, float alpha);
void publishLagControllerParameters(float T, float alpha);
void publishRequestForIntegratorStateChange(int flag_to_publish);
void publishRequestForTimeDelayChange(int time_delay_to_publish);
void publishRequestForPitchErrorChange(float pitch_error_to_publish);
void convertIntoDiscreteTimeParameters(float k, float T, float alpha);
void convertLagIntoDiscreteTimeParameters(float T, float alpha);
};
#endif // CSONECONTROLLERTAB_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The GUI for the Default Controller
//
// ----------------------------------------------------------------------------------
#ifndef DEFAULTCONTROLLERTAB_H
#define DEFAULTCONTROLLERTAB_H
#include <QWidget>
#include <QMutex>
#include <QVector>
#include <QTextStream>
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
// Include the standard message types
//#include "std_msgs/Int32.h"
//#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
// Include the DFALL message types
//#include "dfall_pkg/IntWithHeader.h"
#include "dfall_pkg/SetpointWithHeader.h"
// Include the DFALL service types
#include "dfall_pkg/GetSetpointService.h"
// Include the shared definitions
#include "nodes/Constants.h"
#include "nodes/DefaultControllerConstants.h"
// SPECIFY THE PACKAGE NAMESPACE
//using namespace dfall_pkg;
#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"
#endif
namespace Ui {
class DefaultControllerTab;
}
class DefaultControllerTab : public QWidget
{
Q_OBJECT
public:
explicit DefaultControllerTab(QWidget *parent = 0);
~DefaultControllerTab();
public slots:
void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);
void setMeasuredPose(float x , float y , float z , float roll , float pitch , float yaw , bool isValid);
void poseDataUnavailableSlot();
private slots:
void on_lineEdit_setpoint_new_x_returnPressed();
void on_lineEdit_setpoint_new_y_returnPressed();
void on_lineEdit_setpoint_new_z_returnPressed();
void on_lineEdit_setpoint_new_yaw_returnPressed();
void on_set_setpoint_button_clicked();
void on_default_setpoint_button_clicked();
void on_x_increment_plus_button_clicked();
void on_x_increment_minus_button_clicked();
void on_y_increment_plus_button_clicked();
void on_y_increment_minus_button_clicked();
void on_z_increment_plus_button_clicked();
void on_z_increment_minus_button_clicked();
void on_yaw_increment_plus_button_clicked();
void on_yaw_increment_minus_button_clicked();
private:
Ui::DefaultControllerTab *ui;
// --------------------------------------------------- //
// PRIVATE VARIABLES
// The type of this node, i.e., agent or a coordinator,
// specified as a parameter in the "*.launch" file
int m_type = 0;
// The ID of this node
int m_ID;
// For coordinating multiple agents
std::vector<int> m_vector_of_agentIDs_toCoordinate;
bool m_shouldCoordinateAll = true;
QMutex m_agentIDs_toCoordinate_mutex;
// Mutex for the current state label
QMutex m_label_current_state_mutex;
#ifdef CATKIN_MAKE
// PUBLISHER
// > For requesting the setpoint to be changed
ros::Publisher requestSetpointChangePublisher;
// SUBSCRIBER
// > For being notified when the setpoint is changed
ros::Subscriber setpointChangedSubscriber;
#endif
// --------------------------------------------------- //
// PRIVATE FUNCTIONS
#ifdef CATKIN_MAKE
// For receiving message that the setpoint was changed
void setpointChangedCallback(const dfall_pkg::SetpointWithHeader& newSetpoint);
// Fill the header for a message
void fillSetpointMessageHeader( dfall_pkg::SetpointWithHeader & msg );
// Get the paramters that specify the type and ID
bool getTypeAndIDParameters();
#endif
void publishSetpoint(float x, float y, float z, float yaw);
};
#endif // DEFAULTCONTROLLERTAB_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The GUI bar for selecting which controller is active, and
// for request that paramters are loaded from the respective
// YAML files.
//
// ----------------------------------------------------------------------------------
#ifndef ENABLECONTROLLERLOADYAMLBAR_H
#define ENABLECONTROLLERLOADYAMLBAR_H
#include <QWidget>
#include <QMutex>
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
// Include the standard message types
#include "std_msgs/Int32.h"
#include "std_msgs/Float32.h"
#include <std_msgs/String.h>
// Include the DFALL message types
#include "dfall_pkg/IntWithHeader.h"
#include "dfall_pkg/StringWithHeader.h"
// Include the DFALL service types
// #include "dfall_pkg/AreaBounds.h"
// #include "dfall_pkg/CrazyflieContext.h"
// #include "dfall_pkg/CMQuery.h"
// Include the shared definitions
#include "nodes/Constants.h"
// using namespace dfall_pkg;
#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"
#endif
namespace Ui {
class EnableControllerLoadYamlBar;
}
class EnableControllerLoadYamlBar : public QWidget
{
Q_OBJECT
public:
explicit EnableControllerLoadYamlBar(QWidget *parent = 0);
~EnableControllerLoadYamlBar();
// PUBLIC METHODS FOR TOGGLING THE VISISBLE CONTROLLERS
void showHideController_default_changed();
void showHideController_student_changed();
void showHideController_picker_changed();
void showHideController_tuning_changed();
void showHideController_remote_changed();
void showHideController_template_changed();
void showHideController_csone_changed();
void showHideController_tutorial_changed();
// PUBLIC METHOD FOR TOGGLING THE VISIBILITY OF THE YAML BAR
bool showHide_loadYamlBar_triggered();
// PUBLIC METHODS FOR ENABLING THE TEST MOTORS CONTROLLER
void testMotors_triggered();
public slots:
void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);
private slots:
// ENABLE CONTROLLER BUTTONS ON-CLICK CALLBACK
void on_enable_default_button_clicked();
void on_enable_student_button_clicked();
void on_enable_picker_button_clicked();
void on_enable_tuning_button_clicked();
void on_enable_remote_button_clicked();
void on_enable_template_button_clicked();
void on_enable_csone_button_clicked();
void on_enable_tutorial_button_clicked();
// LOAD YAML BUTTONS ON-CLICK CALLBACK
void on_load_yaml_default_button_clicked();
void on_load_yaml_student_button_clicked();
void on_load_yaml_picker_button_clicked();
void on_load_yaml_tuning_button_clicked();
void on_load_yaml_remote_button_clicked();
void on_load_yaml_template_button_clicked();
void on_load_yaml_csone_button_clicked();
void on_load_yaml_tutorial_button_clicked();
private:
Ui::EnableControllerLoadYamlBar *ui;
// --------------------------------------------------- //
// PRIVATE VARIABLES
// The type of this node, i.e., agent or a coordinator,
// specified as a parameter in the "*.launch" file
int m_type = 0;
// The ID of this node
int m_ID;
// For coordinating multiple agents
std::vector<int> m_vector_of_agentIDs_toCoordinate;
bool m_shouldCoordinateAll = true;
QMutex m_agentIDs_toCoordinate_mutex;
#ifdef CATKIN_MAKE
// PUBLISHERS AND SUBSRIBERS
// > For {take-off,land,motors-off} and controller selection
ros::Publisher commandPublisher;
// > For requesting the loading of yaml files
ros::Publisher m_requestLoadYamlFilenamePublisher;
#endif
// --------------------------------------------------- //
// PRIVATE FUNCTIONS
#ifdef CATKIN_MAKE
// Fill the header for a message
void fillIntMessageHeader( dfall_pkg::IntWithHeader & msg );
void fillStringMessageHeader( dfall_pkg::StringWithHeader & msg );
// Get the paramters that specify the type and ID
bool getTypeAndIDParameters();
#endif
};
#endif // ENABLECONTROLLERLOADYAMLBAR_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The Flying Agent GUI main window.
//
// ----------------------------------------------------------------------------------
#ifndef MAINWINDOW_FLYINGAGENTGUI_H
#define MAINWINDOW_FLYINGAGENTGUI_H
#include <QMainWindow>
#include <QShortcut>
#include <QMutex>
#include <QTextStream>
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
#include "rosNodeThread_for_flyingAgentGUI.h"
// Include the standard message types
#include "std_msgs/Int32.h"
//#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
// Include the DFALL message types
#include "dfall_pkg/StringWithHeader.h"
#include "nodes/Constants.h"
// Namespacing the package
using namespace dfall_pkg;
//using namespace std;
#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"
#endif
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(int argc, char **argv, QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
QShortcut* m_close_GUI_shortcut;
// > For the type of this node,
// i.e., an agent or a coordinator
int m_type = 0;
// > For the ID of this node
int m_ID = 0;
// For coordinating multiple agents
std::vector<int> m_vector_of_agentIDs_toCoordinate;
bool m_shouldCoordinateAll = true;
QMutex m_agentIDs_toCoordinate_mutex;
#ifdef CATKIN_MAKE
rosNodeThread* m_rosNodeThread;
// The namespace into which this parameter service loads yaml parameters
std::string m_parameter_service_namespace;
ros::Publisher m_requestLoadYamlFilenamePublisher;
#endif
// --------------------------------------------------- //
// PRIVATE FUNCTIONS
#ifdef CATKIN_MAKE
bool getTypeAndIDParameters();
#endif
private slots:
// PRIVATE METHODS FOR MENU ITEM CALLBACKS
void on_action_showHide_Coordinator_triggered();
void on_action_showHide_loadYamlBar_triggered();
void on_action_LoadYAML_BatteryMonitor_triggered();
void on_action_LoadYAML_FlyingAgentClientConfig_triggered();
// FOR THE CONTROLLERS MENU
void on_action_showHideController_default_changed();
void on_action_showHideController_student_changed();
void on_action_showHideController_picker_changed();
void on_action_showHideController_tuning_changed();
void on_action_showHideController_remote_changed();
void on_action_showHideController_template_changed();
void on_action_showHideController_csone_changed();
void on_action_showHideController_tutorial_changed();
void on_action_testMotors_triggered();
};
#endif // MAINWINDOW_H
// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat
//
// This file is part of D-FaLL-System.
//
// D-FaLL-System is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// D-FaLL-System is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>.
//
//
// ----------------------------------------------------------------------------------
// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M
// D D F aaa L L S Y Y S T E MM MM
// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M
// D D F a aa L L S Y S T E M M
// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M
//
//
// DESCRIPTION:
// The GUI for the Picker Controller
//
// ----------------------------------------------------------------------------------
#ifndef PICKERCONTROLLERTAB_H
#define PICKERCONTROLLERTAB_H
#include <QWidget>
#include <QMutex>
#include <QTimer>
#include <QVector>
#include <QTextStream>
#define DECIMAL_PLACES_POSITION 2
#define DECIMAL_PLACES_ANGLE_DEGREES 1
#define DECIMAL_PLACES_MASS_GRAMS 1
#define DEFAULT_INCREMENT_POSITION_XY 0.01
#define DEFAULT_INCREMENT_POSITION_Z 0.01
#define DEFAULT_INCREMENT_ANGLE_DEGREES 5
#define DEFAULT_INCREMENT_MASS_GRAMS 0.5
// #define PICKER_STATE_UNKNOWN -1
// #define PICKER_STATE_STANDBY 0
// #define PICKER_STATE_GOTO_START 1
// #define PICKER_STATE_ATTACH 2
// #define PICKER_STATE_LIFT_UP 3
// #define PICKER_STATE_GOTO_END 4
// #define PICKER_STATE_PUT_DOWN 5
// #define PICKER_STATE_SQUAT 6
// #define PICKER_STATE_JUMP 7
// #define PICKER_DEFAULT_X 0
// #define PICKER_DEFAULT_Y 0
// #define PICKER_DEFAULT_Z 0.4
// #define PICKER_DEFAULT_YAW_DEGREES 0
// #define PICKER_DEFAULT_MASS_GRAMS 30
#ifdef CATKIN_MAKE
#include <ros/ros.h>
#include <ros/network.h>
#include <ros/package.h>
// Include the standard message types
//#include "std_msgs/Int32.h"
//#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
// Include the DFALL message types
//#include "dfall_pkg/IntWithHeader.h"
#include "dfall_pkg/SetpointWithHeader.h"
//#include "dfall_pkg/CustomButtonWithHeader.h"
// Include the DFALL service types
#include "dfall_pkg/GetSetpointService.h"
// Include the shared definitions
#include "nodes/Constants.h"
#include "nodes/PickerControllerConstants.h"
// SPECIFY THE PACKAGE NAMESPACE
//using namespace dfall_pkg;
#else
// Include the shared definitions
#include "include/Constants_for_Qt_compile.h"
#include "include/PickerControllerConstants_for_Qt_compile.h"
#endif
namespace Ui {
class PickerControllerTab;
}
class PickerControllerTab : public QWidget
{
Q_OBJECT
public:
explicit PickerControllerTab(QWidget *parent = 0);
~PickerControllerTab();
public slots:
void setAgentIDsToCoordinate(QVector<int> agentIDs , bool shouldCoordinateAll);
void setMeasuredPose(float x , float y , float z , float roll , float pitch , float yaw , bool isValid);
void poseDataUnavailableSlot();
private slots:
// FOR ALL THE GUI BUTTONS AND FIELDS
void on_button_goto_start_clicked();
void on_button_attach_clicked();
void on_button_lift_up_clicked();
void on_button_goto_end_clicked();
void on_button_put_down_clicked();
void on_button_squat_clicked();
void on_button_jump_clicked();
void on_button_standby_clicked();
void on_checkbox_goto_start_clicked();
void on_checkbox_attach_clicked();
void on_checkbox_lift_up_clicked();
void on_checkbox_goto_end_clicked();
void on_checkbox_put_down_clicked();
void on_checkbox_squat_clicked();
void on_checkbox_jump_clicked();
void on_checkbox_standby_clicked();
void on_button_goto_start_inc_minus_x_clicked();
void on_button_goto_start_inc_plus_x_clicked();
void on_button_goto_start_inc_minus_y_clicked();
void on_button_goto_start_inc_plus_y_clicked();
void on_button_goto_start_inc_minus_z_clicked();
void on_button_goto_start_inc_plus_z_clicked();
void on_button_goto_start_inc_minus_yaw_clicked();
void on_button_goto_start_inc_plus_yaw_clicked();
void on_button_attach_inc_minus_z_clicked();
void on_button_attach_inc_plus_z_clicked();
void on_button_lift_up_inc_minus_z_clicked();
void on_button_lift_up_inc_plus_z_clicked();
void on_button_lift_up_inc_minus_mass_clicked();
void on_button_lift_up_inc_plus_mass_clicked();
void on_button_goto_end_inc_minus_x_clicked();
void on_button_goto_end_inc_plus_x_clicked();
void on_button_goto_end_inc_minus_y_clicked();
void on_button_goto_end_inc_plus_y_clicked();
void on_button_goto_end_inc_minus_yaw_clicked();
void on_button_goto_end_inc_plus_yaw_clicked();
void on_button_put_down_inc_minus_z_clicked();
void on_button_put_down_inc_plus_z_clicked();
void on_button_squat_inc_minus_z_clicked();
void on_button_squat_inc_plus_z_clicked();
void on_button_jump_inc_minus_z_clicked();
void on_button_jump_inc_plus_z_clicked();
void on_button_stanby_inc_minus_x_clicked();
void on_button_stanby_inc_plus_x_clicked();
void on_button_stanby_inc_minus_y_clicked();
void on_button_stanby_inc_plus_y_clicked();
void on_button_stanby_inc_minus_z_clicked();
void on_button_stanby_inc_plus_z_clicked();
void on_button_stanby_inc_minus_yaw_clicked();
void on_button_stanby_inc_plus_yaw_clicked();
void on_button_stanby_inc_minus_mass_clicked();
void on_button_stanby_inc_plus_mass_clicked();
void on_lineEdit_goto_start_x_editingFinished();
void on_lineEdit_goto_start_y_editingFinished();
void on_lineEdit_goto_start_z_editingFinished();
void on_lineEdit_goto_start_yaw_editingFinished();
void on_lineEdit_attach_z_editingFinished();
void on_lineEdit_lift_up_z_editingFinished();
void on_lineEdit_lift_up_mass_editingFinished();
void on_lineEdit_goto_end_x_editingFinished();
void on_lineEdit_goto_end_y_editingFinished();
void on_lineEdit_goto_end_yaw_editingFinished();
void on_lineEdit_put_down_z_editingFinished();
void on_lineEdit_squat_z_editingFinished();
void on_lineEdit_jump_z_editingFinished();
void on_lineEdit_standby_x_editingFinished();
void on_lineEdit_standby_y_editingFinished();
void on_lineEdit_standby_z_editingFinished();
void on_lineEdit_standby_yaw_editingFinished();
void on_lineEdit_standby_mass_editingFinished();
void on_lineEdit_increment_x_editingFinished();
void on_lineEdit_increment_y_editingFinished();
void on_lineEdit_increment_z_editingFinished();
void on_lineEdit_increment_yaw_editingFinished();
void on_lineEdit_increment_mass_editingFinished();
private:
Ui::PickerControllerTab *ui;
// --------------------------------------------------- //
// PRIVATE VARIABLES
// The type of this node, i.e., agent or a coordinator,
// specified as a parameter in the "*.launch" file
int m_type = 0;
// The ID of this node
int m_ID;
// For coordinating multiple agents
std::vector<int> m_vector_of_agentIDs_toCoordinate;
bool m_shouldCoordinateAll = true;
QMutex m_agentIDs_toCoordinate_mutex;
// THE CURRENT STATE OF THE PICKER
int m_current_picker_state = PICKER_STATE_UNKNOWN;
QMutex m_current_picker_state_mutex;
#ifdef CATKIN_MAKE
// PUBLISHER
// > For requesting the setpoint to be changed
ros::Publisher requestSetpointChangePublisher;
// SUBSCRIBER
// > For being notified when the setpoint is changed
ros::Subscriber setpointChangedSubscriber;
#endif
// --------------------------------------------------- //
// PRIVATE FUNCTIONS
#ifdef CATKIN_MAKE
// For receiving message that the setpoint was changed
void setpointChangedCallback(const dfall_pkg::SetpointWithHeader& newSetpoint);
// Fill the header for a message
void fillSetpointMessageHeader( dfall_pkg::SetpointWithHeader & msg );
// Get the paramters that specify the type and ID
bool getTypeAndIDParameters();
#endif
void publish_setpoint_if_current_state_matches(QVector<int> state_to_match);
void publish_request_setpoint_change_for_state(int state_to_publish);
};
#endif // PICKERCONTROLLERTAB_H