Commit d03f76cc authored by beuchatp's avatar beuchatp
Browse files

Finished setting up the Battery monitoring node and new parameter service...

Finished setting up the Battery monitoring node and new parameter service style to match. Needs a GUI reload Yaml to be added and needs to be tested.
parent 3dfa2b1d
......@@ -205,7 +205,11 @@ add_message_files(
SetpointV2.msg
CrazyflieEntry.msg
CrazyflieDB.msg
#----------------------------------------------------------------------
#------------------------
IntWithHeader.msg
FloatWithHeader.msg
StringWithHeader.msg
#------------------------
DebugMsg.msg
CustomButton.msg
ViconSubscribeObjectName.msg
......@@ -219,7 +223,6 @@ add_message_files(
# )
add_service_files(
FILES
LoadYamlFiles.srv
Controller.srv
CMRead.srv
CMQuery.srv
......
......@@ -130,7 +130,7 @@ CoordinatorRow::CoordinatorRow(QWidget *parent, int agentID) :
flyingStateSubscriber = base_nodeHandle.subscribe("PPSClient/flyingState", 1, &CoordinatorRow::flyingStateChangedCallback, this);
// > For changes in the database that defines {agentID,cfID,flying zone} links
databaseChangedSubscriber = dfall_root_nodeHandle.subscribe("/my_GUI/DBChanged", 1, &CoordinatorRow::databaseChangedCallback, this);;
centralManagerDatabaseService = dfall_root_nodeHandle.serviceClient<CMQuery>("/CentralManagerService/Query", false);
centralManagerDatabaseService = dfall_root_nodeHandle.serviceClient<CMQuery>("CentralManagerService/Query", false);
// > For updating the controller that is currently operating
controllerUsedSubscriber = base_nodeHandle.subscribe("PPSClient/controllerUsed", 1, &CoordinatorRow::controllerUsedChangedCallback, this);
......
......@@ -192,7 +192,9 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
}
// Then, Central manager
centralManager = nodeHandle.serviceClient<CMQuery>("/CentralManagerService/Query", false);
// CREATE A NODE HANDLE TO THE ROOT OF THE D-FaLL SYSTEM
ros::NodeHandle dfall_root_nodeHandle("/dfall");
centralManager = dfall_root_nodeHandle.serviceClient<CMQuery>("CentralManagerService/Query", false);
loadCrazyflieContext();
......
......@@ -42,20 +42,28 @@
// ----------------------------------------------------------------------------------
#include <stdlib.h>
#include <iostream>
#include <string>
#include <ros/ros.h>
#include <ros/package.h>
#include <ros/network.h>
// Include the standard message types
#include "std_msgs/Int32.h"
#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
#include "d_fall_pps/Controller.h"
#include "d_fall_pps/LoadYamlFiles.h"
// Include the DFALL message types
#include "d_fall_pps/IntWithHeader.h"
// Include the shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
// SPECIFY THE PACKAGE NAMESPACE
using namespace d_fall_pps;
//using namespace std;
// ----------------------------------------------------------------------------------
......@@ -117,18 +125,15 @@
// The ID of the agent that this node is monitoring
int m_agentID;
// The ID of the agent that can coordinate this node
int m_coordID;
// NAMESPACES FOR THE PARAMETER SERVICES
// > For the paramter service of this agent
std::string m_namespace_to_own_agent_parameter_service;
// > For the parameter service of the coordinator
std::string m_namespace_to_coordinator_parameter_service;
// SERVICE CLIENTS FOR THE PARAMETER SERVICES
// > For the paramter service of this agent
ros::ServiceClient m_own_agent_parameter_service_client;
// > For the parameter service of the coordinator
ros::ServiceClient m_coordinator_parameter_service_client;
......@@ -198,5 +203,29 @@ void updateBatteryStateBasedOnLevel(int level);
// LOAD YAML PARAMETER FUNCTIONS
void fetchYamlParameters(ros::NodeHandle& nodeHandle);
void processFetchedParameters();
void yamlReadyForFetchCallback(const IntWithHeader & msg);
float getParameterFloat(ros::NodeHandle& nodeHandle, std::string name);
int getParameterInt(ros::NodeHandle& nodeHandle, std::string name);
\ No newline at end of file
int getParameterInt(ros::NodeHandle& nodeHandle, std::string name);
// FUNCTIONS FOR TEMPLATING A GET STUFF CLASS
// Get the "agentID" and "coordID" from the client node
bool getAgentIDandCoordIDfromClientNode( std::string client_namespace , int * agentID_ref , int * coordID_ref);
// Construct the namespaces for the parameter services
void getConstructNamespaceForCoordinatorParameterService( int coordID, std::string & coord_param_service_namespace );
// Check the header of a message for whether it is relevant
bool checkMessageHeader( int agentID , bool shouldCheckForID , const std::vector<uint> & agentIDs );
\ No newline at end of file
......@@ -25,15 +25,72 @@
//
//
// DESCRIPTION:
// The service that manages the loading of YAML parameters
// Constants that are used across multiple files
//
// ----------------------------------------------------------------------------------
// DEFINES THAT ARE SHARED WITH OTHER FILES
// ----------------------------------------------------------------------------------
// 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
// OLD STUFF FOR LOADING YAML FILES
// For which controller parameters to load from file
#define LOAD_YAML_SAFE_CONTROLLER_AGENT 1
#define LOAD_YAML_DEMO_CONTROLLER_AGENT 2
......
......@@ -59,7 +59,7 @@
#include "d_fall_pps/CustomButton.h"
// Include the Parameter Service shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
#include <std_msgs/Int32.h>
......
......@@ -58,7 +58,7 @@
#include "std_msgs/Float32.h"
// Include the Parameter Service shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
// Need for having a ROS "bag" to store data for post-analysis
//#include <rosbag/bag.h>
......
......@@ -47,15 +47,19 @@
#include <ros/ros.h>
#include <ros/package.h>
#include <ros/network.h>
// Include the standard message types
#include "std_msgs/Int32.h"
//#include "std_msgs/Float32.h"
//#include <std_msgs/String.h>
#include <std_msgs/String.h>
#include "d_fall_pps/Controller.h"
#include "d_fall_pps/LoadYamlFiles.h"
// Include the DFALL message types
#include "d_fall_pps/IntWithHeader.h"
//#include "d_fall_pps/FloatWithHeader.h"
#include "d_fall_pps/StringWithHeader.h"
// Include the shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
// ----------------------------------------------------------------------------------
......@@ -89,20 +93,17 @@ using namespace d_fall_pps;
// The type of this node, i.e., agent or a coordinator, specified as a parameter in the
// "*.launch" file
int my_type = 0;
int m_type = 0;
// The ID of this agent, i.e., the ID of this computer in the case that this computer is
// and agent
std::string my_agentID = "000";
int m_ID = 0;
// Publisher that notifies the relevant nodes when the YAML paramters have been loaded
// from file into ram/cache, and hence are ready to be fetched
ros::Publisher controllerYamlReadyForFetchPublisher;
// The namespace into which this parameter service loads yaml parameters
std::string m_base_namespace;
std::string m_base_namespace;
ros::Subscriber requestLoadControllerYamlSubscriber_agent_to_self;
// ----------------------------------------------------------------------------------
......@@ -121,4 +122,8 @@ ros::Subscriber requestLoadControllerYamlSubscriber_agent_to_self;
void requestLoadControllerYamlCallback(const std_msgs::Int32& msg);
bool loadYamlFiles(LoadYamlFiles::Request &request, LoadYamlFiles::Response &response);
void requestLoadYamlFilenameCallback(const StringWithHeader& yamlFilenameToLoad);
bool getTypeAndIDParameters();
bool constructNamespaces();
......@@ -60,7 +60,7 @@
#include "d_fall_pps/CustomButton.h"
// Include the Parameter Service shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
#include <std_msgs/Int32.h>
#include <std_msgs/Float32.h>
......
......@@ -65,7 +65,7 @@
#include "d_fall_pps/ViconSubscribeObjectName.h"
// Include the Parameter Service shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
#include <std_msgs/Int32.h>
......
......@@ -59,7 +59,7 @@
#include <std_msgs/Int32.h>
// Include the shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
......
......@@ -59,7 +59,7 @@
#include "d_fall_pps/CustomButton.h"
// Include the Parameter Service shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
#include <std_msgs/Int32.h>
......
......@@ -65,7 +65,7 @@
#include "d_fall_pps/ViconSubscribeObjectName.h"
// Include the Parameter Service shared definitions
#include "nodes/ParameterServiceDefinitions.h"
#include "nodes/Constants.h"
#include <std_msgs/Int32.h>
......
......@@ -3,6 +3,9 @@
<!-- INPUT ARGUMENT OF THE AGENT's ID -->
<arg name="agentID" default="$(optenv DFALL_DEFAULT_AGENT_ID)" />
<!-- INPUT ARGUMENT OF THE COORDINATOR's ID -->
<arg name="coordID" default="$(optenv DFALL_DEFAULT_COORD_ID)" />
<!-- INPUT ARGUMENT FOR LAUNCHING A GUI OR NOT -->
<arg name="withGUI" default="true" />
......@@ -33,6 +36,7 @@
>
<rosparam command="load" file="$(find d_fall_pps)/param/ClientConfig.yaml" />
<param name="agentID" value="$(arg agentID)" />
<param name="coordID" value="$(arg coordID)" />
</node>
<!-- BATTERY MONITOR -->
......@@ -118,8 +122,8 @@
<param name="agentID" type="str" value="$(arg agentID)" />
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/YamlFileNames.yaml"
ns = "YamlFileNames"
file = "$(find d_fall_pps)/param/BatteryMonitor.yaml"
ns = "BatteryMonitor"
/>
<rosparam
command = "load"
......
# TO RUN THE SYSTEM FULLY ON THE LOCAL COMPUTER:
# export ROS_MASTER_URI=http://localhost:11311
# TO RUN THE SYSTEM ON A DEFAULT CONFIGURATION OF THE NETWROK:
export ROS_MASTER_URI=http://teacher:11311
# OTHER NECESSARY ENVIRONMENT VARIABLES:
export ROS_IP=$(hostname -I | awk '{print $1;}')
export DFALL_DEFAULT_AGENT_ID=$(cat /etc/dfall_default_agent_id)
export DFALL_DEFAULT_COORD_ID=$(cat /etc/dfall_default_coord_id)
export ROS_NAMESPACE='dfall'
export ROS_NAMESPACE='dfall'
\ No newline at end of file
<launch>
<!-- INPUT ARGUMENT OF THE AGENT's ID -->
<!-- INPUT ARGUMENT OF THE COORDINATOR's ID -->
<arg name="coordID" default="$(optenv DFALL_DEFAULT_COORD_ID)" />
<!-- INPUT ARGUMENT FOR LAUNCHING A GUI OR NOT -->
<arg name="withGUI" default="true" />
<!-- Example of how to use the value in coordID -->
<!-- <param name="param" value="$(arg coordID)"/> -->
......@@ -12,14 +15,68 @@
<group ns="coord$(arg coordID)">
<!-- COORDINATOR GUI -->
<group if="$(arg withGUI)">
<node
pkg="d_fall_pps"
name="flyingAgentGUI"
output="screen"
type="flyingAgentGUI"
>
<param name="type" type="str" value="coordinator" />
<param name="coordID" value="$(arg coordID)" />
</node>
</group>
<!-- PARAMETER SERVICE -->
<node
pkg="d_fall_pps"
name="flyingAgentGUI"
output="screen"
type="flyingAgentGUI"
pkg = "d_fall_pps"
name = "ParameterService"
output = "screen"
type = "ParameterService"
>
<param name="type" type="str" value="coordinator" />
<param name="coordID" type="str" value="$(arg coordID)" />
<param name="coordID" value="$(arg coordID)" />
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/YamlFileNames.yaml"
ns = "YamlFileNames"
/>
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/SafeController.yaml"
ns = "SafeController"
/>
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/DemoController.yaml"
ns = "DemoController"
/>
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/StudentController.yaml"
ns = "StudentController"
/>
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/MpcController.yaml"
ns = "MpcController"
/>
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/RemoteController.yaml"
ns = "RemoteController"
/>
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/TuningController.yaml"
ns = "TuningController"
/>
<rosparam
command = "load"
file = "$(find d_fall_pps)/param/PickerController.yaml"
ns = "PickerController"
/>
</node>
</group>
......
......@@ -10,12 +10,4 @@
<node pkg="d_fall_pps" name="my_GUI" output="screen" type="my_GUI">
</node>
<!-- PARAMETER SERVICE -->
<node pkg="d_fall_pps" name="ParameterService" output="screen" type="ParameterService">
<param name="type" type="str" value="coordinator" />
<param name="agentID" value="0" />
<rosparam command="load" file="$(find d_fall_pps)/param/SafeController.yaml" ns="SafeController" />
<rosparam command="load" file="$(find d_fall_pps)/param/DemoController.yaml" ns="CustomController" />
</node>
</launch>
float32 data
bool shouldCheckForID
uint8[] agentIDs
\ No newline at end of file
uint32 data
bool shouldCheckForID
uint32[] agentIDs
\ No newline at end of file
string data
bool shouldCheckForID
uint8[] agentIDs
\ No newline at end of file
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