Commit 24f5990a authored by Paul Beuchat's avatar Paul Beuchat
Browse files

Started to update namespace conventions to new standards

parent fe2f0673
......@@ -108,9 +108,9 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
requestLoadControllerYaml_from_my_GUI_Subscriber = nodeHandle.subscribe("/my_GUI/requestLoadControllerYaml", 1, &MainWindow::requestLoadControllerYaml_from_my_GUI_Callback, this);
// First get student ID
if(!nh_PPSClient.getParam("studentID", m_student_id))
if(!nh_PPSClient.getParam("agentID", m_student_id))
{
ROS_ERROR("Failed to get studentID");
ROS_ERROR("Failed to get agentID");
}
// Then, Central manager
......
......@@ -136,8 +136,8 @@ using namespace d_fall_pps;
// V A A R R III A A BBBB LLLLL EEEEE SSSS
// ----------------------------------------------------------------------------------
// "studentID", gives namespace and identifier in CentralManagerService
int studentID;
// "agentID", gives namespace and identifier in CentralManagerService
int agentID;
// The safe controller specified in the ClientConfig.yaml, is considered stable
ros::ServiceClient safeController;
......
......@@ -100,7 +100,7 @@ int my_type = 0;
// The ID of this agent, i.e., the ID of this computer in the case that this computer is
// and agent
int my_agentID = 0;
std::string my_agentID = "000";
// 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
......
<launch>
<!-- INPUT ARGUMENT OF THE AGENT's ID -->
<arg name="agentid" default="$(optenv DFALL_DEFAULT_ID)" />
<!-- Example of how to use the value in agentid -->
<!-- <param name="param" value="$(arg agentid)"/> -->
<group ns="agent$(arg agentid)">
<!-- CRAZY RADIO -->
<node
pkg = "d_fall_pps"
name = "CrazyRadio"
output = "screen"
type = "CrazyRadio.py"
>
<rosparam command="load" file="$(find d_fall_pps)/param/ClientConfig.yaml" />
</node>
<!-- PPS CLIENT -->
<node
pkg = "d_fall_pps"
name = "PPSClient"
output = "screen"
type = "PPSClient"
>
<rosparam command="load" file="$(find d_fall_pps)/param/ClientConfig.yaml" />
<param name="agentID" value="$(arg agentid)" />
</node>
<!-- SAFE CONTROLLER -->
<node
pkg = "d_fall_pps"
name = "SafeControllerService"
output = "screen"
type = "SafeControllerService"
>
</node>
<!-- DEMO CONTROLLER -->
<node
pkg = "d_fall_pps"
name = "DemoControllerService"
output = "screen"
type = "DemoControllerService"
>
</node>
<!-- PARAMETER SERVICE -->
<node
pkg = "d_fall_pps"
name = "ParameterService"
output = "screen"
type = "ParameterService"
>
<param name="type" type="str" value="agent" />
<param name="agentID" type="str" value="$(arg agentid)" />
<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"
/>
</node>
<!-- AGENT GUI (aka. the "student GUI") -->
<node
pkg = "d_fall_pps"
name = "student_GUI"
output = "screen"
type = "student_GUI">
</node>
</group>
</launch>
export ROS_MASTER_URI=http://teacher:11311
export ROS_IP=$(hostname -I | awk '{print $1;}')
export ROS_NAMESPACE=$(cat /etc/StudentID)
export DFALL_DEFAULT_ID=$(cat /etc/dfall_default_id)
export ROS_NAMESPACE='dfall'
<launch>
<!-- CRAZY RADIO -->
<node pkg="d_fall_pps" name="CrazyRadio" output="screen" type="CrazyRadio.py">
<rosparam command="load" file="$(find d_fall_pps)/param/ClientConfig.yaml" />
</node>
<!-- PPS CLIENT -->
<node pkg="d_fall_pps" name="PPSClient" output="screen" type="PPSClient">
<rosparam command="load" file="$(find d_fall_pps)/param/ClientConfig.yaml" />
<param name="studentID" value="$(optenv ROS_NAMESPACE)" />
</node>
<!-- SAFE CONTROLLER -->
<node pkg="d_fall_pps" name="SafeControllerService" output="screen" type="SafeControllerService">
</node>
<!-- DEMO CONTROLLER -->
<node pkg="d_fall_pps" name="DemoControllerService" output="screen" type="DemoControllerService">
</node>
<!-- PARAMETER SERVICE -->
<node pkg="d_fall_pps" name="ParameterService" output="screen" type="ParameterService">
<param name="type" type="str" value="agent" />
<param name="agentID" value="$(optenv ROS_NAMESPACE)" />
<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" />
</node>
<!-- AGENT GUI (aka. the "student GUI") -->
<node pkg="d_fall_pps" name="student_GUI" output="screen" type="student_GUI">
</node>
</launch>
......@@ -1789,6 +1789,10 @@ int main(int argc, char* argv[]) {
// the "~" indcates that "self" is the node handle assigned to this variable.
ros::NodeHandle nodeHandle("~");
// Get the namespace of this "DemoControllerService" node
std::string m_namespace = ros::this_node::getNamespace();
ROS_INFO_STREAM("For DemoController, ros::this_node::getNamespace() = " << m_namespace);
// Get the agent ID as the "ROS_NAMESPACE" this computer.
// NOTES:
// > If you look at the "Student.launch" file in the "launch" folder, you will see
......@@ -1797,15 +1801,14 @@ int main(int argc, char* argv[]) {
// This line of code adds a parameter named "studentID" to the "PPSClient"
// > Thus, to get access to this "studentID" paremeter, we first need to get a handle
// to the "PPSClient" node within which this controller service is nested.
// Get the namespace of this "DemoControllerService" node
std::string m_namespace = ros::this_node::getNamespace();
// Get the handle to the "PPSClient" node
ros::NodeHandle PPSClient_nodeHandle(m_namespace + "/PPSClient");
// Get the value of the "studentID" parameter into the instance variable "my_agentID"
if(!PPSClient_nodeHandle.getParam("studentID", my_agentID))
if(!PPSClient_nodeHandle.getParam("agentID", my_agentID))
{
// Throw an error if the student ID parameter could not be obtained
ROS_ERROR("Failed to get studentID from PPSClient");
ROS_ERROR("Failed to get agentID from PPSClient");
}
......@@ -1856,7 +1859,7 @@ int main(int argc, char* argv[]) {
// PRINT OUT SOME INFORMATION
// Let the user know what namespaces are being used for linking to the parameter service
ROS_INFO_STREAM("The namespace string for accessing the Paramter Services are:");
ROS_INFO_STREAM("For DemoController: the namespace strings for accessing the Paramter Services are:");
ROS_INFO_STREAM("namespace_to_own_agent_parameter_service = " << namespace_to_own_agent_parameter_service);
ROS_INFO_STREAM("namespace_to_coordinator_parameter_service = " << namespace_to_coordinator_parameter_service);
......
......@@ -359,8 +359,8 @@ void viconCallback(const ViconData& viconData) {
void loadCrazyflieContext() {
CMQuery contextCall;
contextCall.request.studentID = studentID;
ROS_INFO_STREAM("StudentID:" << studentID);
contextCall.request.studentID = agentID;
ROS_INFO_STREAM("AgentID:" << agentID);
CrazyflieContext new_context;
......@@ -574,8 +574,8 @@ void fetchYamlParametersForSafeController(ros::NodeHandle& nodeHandle)
// > Load the paramters from the Client Config YAML file
void fetchClientConfigParameters(ros::NodeHandle& nodeHandle)
{
if(!nodeHandle.getParam("studentID", studentID)) {
ROS_ERROR("Failed to get studentID");
if(!nodeHandle.getParam("agentID", agentID)) {
ROS_ERROR("Failed to get agentID");
}
if(!nodeHandle.getParam("strictSafety", strictSafety)) {
ROS_ERROR("Failed to get strictSafety param");
......
......@@ -245,7 +245,7 @@ int main(int argc, char* argv[])
case TYPE_AGENT:
{
//m_ros_namespace = ros::this_node::getNamespace();
m_ros_namespace = "/" + std::to_string(my_agentID) + '/' + "ParameterService";
m_ros_namespace = "/agent" + my_agentID + '/' + "ParameterService";
ROS_INFO_STREAM("This Paramter Sercice will load .yaml file parameters into the 'base' namespace: " << m_ros_namespace);
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