Commit fe61c0fd authored by beuchatp's avatar beuchatp
Browse files

Now compiles, needs testing

parent 31032427
......@@ -210,6 +210,7 @@ add_message_files(
FloatWithHeader.msg
StringWithHeader.msg
SetpointWithHeader.msg
CustomButtonWithHeader.msg
#------------------------
DebugMsg.msg
CustomButton.msg
......
......@@ -4,6 +4,7 @@
#include <QWidget>
#include <QMutex>
#include <QVector>
#include <QLineEdit>
#include <QTextStream>
#ifdef CATKIN_MAKE
......@@ -19,7 +20,7 @@
// Include the DFALL message types
//#include "d_fall_pps/IntWithHeader.h"
#include "d_fall_pps/SetpointWithHeader.h"
#include "d_fall_pps/CustomButtonWithHeader"
#include "d_fall_pps/CustomButtonWithHeader.h"
// Include the DFALL service types
#include "d_fall_pps/GetSetpointService.h"
......
......@@ -556,7 +556,7 @@ void DefaultControllerTab::setAgentIDsToCoordinate(QVector<int> agentIDs , bool
ros::NodeHandle agent_base_nodeHandle(agent_base_namespace.toStdString());
// // > Request the current setpoint
ros::ServiceClient getCurrentSetpointServiceClient = agent_base_nodeHandle.serviceClient<d_fall_pps::IntIntService>("DefaultControllerService/GetCurrentSetpoint", false);
ros::ServiceClient getCurrentSetpointServiceClient = agent_base_nodeHandle.serviceClient<d_fall_pps::GetSetpointService>("DefaultControllerService/GetCurrentSetpoint", false);
d_fall_pps::GetSetpointService getSetpointCall;
getSetpointCall.request.data = 0;
getCurrentSetpointServiceClient.waitForExistence(ros::Duration(2.0));
......
......@@ -47,7 +47,7 @@ StudentControllerTab::StudentControllerTab(QWidget *parent) :
}
// CREATE THE CUSTOM BUTTON PRESSED PUBLISHED
customButtonPublisher = nodeHandle_for_this_gui.advertise<CustomButton>("StudentControllerService/CustomButtonPressed", 1);
customButtonPublisher = nodeHandle_for_this_gui.advertise<d_fall_pps::CustomButtonWithHeader>("StudentControllerService/CustomButtonPressed", 1);
#endif
......@@ -87,10 +87,10 @@ void StudentControllerTab::publish_custom_button_command(int button_index , QLin
// Fill in the button index
msg.button_index = button_index;
// Get the line edit data, as a float if possible
bool isFloat = false;
float lineEdit_as_float = (lineEdit_pointer->text()).toFloat(isFloat);
bool isValidFloat = false;
float lineEdit_as_float = (lineEdit_pointer->text()).toFloat(&isValidFloat);
// Fill in the data
if (isFloat)
if (isValidFloat)
msg.float_data = lineEdit_as_float;
else
msg.string_data = (lineEdit_pointer->text()).toStdString();
......@@ -105,24 +105,25 @@ void StudentControllerTab::publish_custom_button_command(int button_index , QLin
void StudentControllerTab::on_custom_button_1_clicked()
{
#ifdef CATKIN_MAKE
// Initialise the message as a local variable
d_fall_pps::CustomButtonWithHeader msg;
// Fill the header of the message
fillCustomButtonMessageHeader( msg );
// Fill in the button index
msg.button_index = 1;
// Get the line edit data, as a float if possible
bool isFloat = false;
float lineEdit_as_float = (ui->lineEdit_custom_1->text()).toFloat(isFloat);
// Fill in the data
if (isFloat)
msg.float_data = lineEdit_as_float;
else
msg.string_data = (ui->lineEdit_custom_1->text()).toStdString();
// Publish the setpoint
this->customButtonPublisher.publish(msg);
// Inform the user about the change
ROS_INFO("[STUDENT CONTROLLER TAB GUI] button 1 clicked.");
publish_custom_button_command(1,ui->lineEdit_custom_1);
// // Initialise the message as a local variable
// d_fall_pps::CustomButtonWithHeader msg;
// // Fill the header of the message
// fillCustomButtonMessageHeader( msg );
// // Fill in the button index
// msg.button_index = 1;
// // Get the line edit data, as a float if possible
// bool isFloat = false;
// float lineEdit_as_float = (ui->lineEdit_custom_1->text()).toFloat(isFloat);
// // Fill in the data
// if (isFloat)
// msg.float_data = lineEdit_as_float;
// else
// msg.string_data = (ui->lineEdit_custom_1->text()).toStdString();
// // Publish the setpoint
// this->customButtonPublisher.publish(msg);
// // Inform the user about the change
// ROS_INFO("[STUDENT CONTROLLER TAB GUI] button 1 clicked.");
#endif
}
......@@ -655,7 +656,7 @@ void StudentControllerTab::setAgentIDsToCoordinate(QVector<int> agentIDs , bool
ros::NodeHandle agent_base_nodeHandle(agent_base_namespace.toStdString());
// // > Request the current setpoint
ros::ServiceClient getCurrentSetpointServiceClient = agent_base_nodeHandle.serviceClient<d_fall_pps::IntIntService>("StudentControllerService/GetCurrentSetpoint", false);
ros::ServiceClient getCurrentSetpointServiceClient = agent_base_nodeHandle.serviceClient<d_fall_pps::GetSetpointService>("StudentControllerService/GetCurrentSetpoint", false);
d_fall_pps::GetSetpointService getSetpointCall;
getSetpointCall.request.data = 0;
getCurrentSetpointServiceClient.waitForExistence(ros::Duration(2.0));
......@@ -747,7 +748,7 @@ void StudentControllerTab::fillSetpointMessageHeader( d_fall_pps::SetpointWithHe
#ifdef CATKIN_MAKE
// Fill the header for a message
void fillCustomButtonMessageHeader( d_fall_pps::CustomButtonWithHeader & msg )
void StudentControllerTab::fillCustomButtonMessageHeader( d_fall_pps::CustomButtonWithHeader & msg )
{
switch (m_type)
{
......
......@@ -249,7 +249,7 @@ void TopBanner::on_emergency_stop_button_clicked()
{
#ifdef CATKIN_MAKE
d_fall_pps::IntWithHeader msg;
msg.shouldCheckIDs = false;
msg.shouldCheckForID = false;
msg.data = CMD_CRAZYFLY_MOTORS_OFF;
this->emergencyStopPublisher.publish(msg);
ROS_INFO("[TOP BANNER GUI] EMERGENCY STOP button clicked");
......
......@@ -644,8 +644,9 @@ void customCommandReceivedCallback(const CustomButtonWithHeader& commandReceived
if (isRevelant)
{
// Extract the data from the message
int custom_button_index = commandReceived.button_index;
float custom_command_code = commandReceived.command_code;
int custom_button_index = commandReceived.button_index;
float float_data = commandReceived.float_data;
//std::string string_data = commandReceived.string_data;
// Switch between the button pressed
switch(custom_button_index)
......@@ -675,7 +676,7 @@ void customCommandReceivedCallback(const CustomButtonWithHeader& commandReceived
case 3:
{
// Let the user know that this part of the code was triggered
ROS_INFO_STREAM("[STUDENT CONTROLLER] Button 3 received in controller, with command code:" << custom_command_code );
ROS_INFO_STREAM("[STUDENT CONTROLLER] Button 3 received in controller, with message.float_data = " << float_data );
// Code here to respond to custom button 3
break;
......@@ -684,7 +685,7 @@ void customCommandReceivedCallback(const CustomButtonWithHeader& commandReceived
default:
{
// Let the user know that the command was not recognised
ROS_INFO_STREAM("[DEMO CONTROLLER] A button clicked command was received in the controller but not recognised, message.button_index = " << custom_button_index << ", and message.command_code = " << custom_command_code );
ROS_INFO_STREAM("[DEMO CONTROLLER] A button clicked command was received in the controller but not recognised, message.button_index = " << custom_button_index << ", and message.float_data = " << float_data );
break;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment