Commit 8f14b592 authored by beuchatp's avatar beuchatp
Browse files

Web interface now working for launching both the master and agent. VERY...

Web interface now working for launching both the master and agent. VERY IMPORTANT is the command added to the web interface install script that the www-data user must be added to the plugdev group so that nodes launched by the web interface have permission to access the CrazyRadio USB dongle
parent c0a39616
<launch>
<!-- 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 EMULATING THE CRAZY RADIO -->
<arg name="emulateRadio" default="false" />
<!-- Example of how to use the value in agentID -->
<!-- <param name="param" value="$(arg agentID)"/> -->
<!-- Example of how to specify the agentID from command line -->
<!-- roslaunch dfall_pkg agentID:=1 -->
<!-- Example of how to specify the withGUI from command line -->
<!-- roslaunch dfall_pkg withGUI:=false -->
<group ns="$(eval 'agent' + str(agentID).zfill(3))">
<!-- CRAZY RADIO -->
<group unless="$(arg emulateRadio)">
<node
pkg = "dfall_pkg"
name = "CrazyRadio"
output = "screen"
type = "CrazyRadio.py"
>
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/BatteryMonitor.yaml"
ns = "CrazyRadioCopyOfBatteryMonitor"
/>
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/CrazyRadioConfig.yaml"
ns = "CrazyRadioConfig"
/>
</node>
</group>
<group if="$(arg emulateRadio)">
<node
pkg = "dfall_pkg"
name = "CrazyRadio"
output = "screen"
type = "CrazyRadioEmulator"
>
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/CrazyRadioConfig.yaml"
ns = "CrazyRadioConfig"
/>
</node>
</group>
<!-- FLYING AGENT CLIENT -->
<node
pkg = "dfall_pkg"
name = "FlyingAgentClient"
output = "screen"
type = "FlyingAgentClient"
>
<param name="agentID" value="$(arg agentID)" />
<param name="coordID" value="$(arg coordID)" />
</node>
<!-- BATTERY MONITOR -->
<node
pkg = "dfall_pkg"
name = "BatteryMonitor"
output = "screen"
type = "BatteryMonitor"
>
</node>
<!-- DEFAULT CONTROLLER -->
<node
pkg = "dfall_pkg"
name = "DefaultControllerService"
output = "screen"
type = "DefaultControllerService"
>
</node>
<!-- STUDENT CONTROLLER -->
<node
pkg = "dfall_pkg"
name = "StudentControllerService"
output = "screen"
type = "StudentControllerService"
>
</node>
<!-- TEST MOTORS CONTROLLER -->
<node
pkg = "dfall_pkg"
name = "TestMotorsControllerService"
output = "screen"
type = "TestMotorsControllerService"
>
</node>
<!-- PARAMETER SERVICE -->
<node
pkg = "dfall_pkg"
name = "ParameterService"
output = "screen"
type = "ParameterService"
>
<param name="type" type="str" value="agent" />
<param name="agentID" value="$(arg agentID)" />
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/YamlFileNames.yaml"
ns = "YamlFileNames"
/>
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/FlyingAgentClientConfig.yaml"
ns = "FlyingAgentClientConfig"
/>
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/BatteryMonitor.yaml"
ns = "BatteryMonitor"
/>
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/DefaultController.yaml"
ns = "DefaultController"
/>
<rosparam
command = "load"
file = "$(find dfall_pkg)/param/StudentController.yaml"
ns = "StudentController"
/>
</node>
</group>
</launch>
<launch>
<!-- INPUT ARGUMENT FOR EMULATING THE MOTION CAPTURE -->
<arg name="emulateMocap" default="false" />
<!-- Example of how to specify the emulateMocap from command line -->
<!-- roslaunch dfall_pkg emulateMocap:=true -->
<!-- CENTRAL MANAGER -->
<node
pkg="dfall_pkg"
name="CentralManagerService"
output="screen"
type="CentralManagerService"
>
</node>
<!-- VICON DATA PUBLISHER -->
<group unless="$(arg emulateMocap)">
<node
pkg="dfall_pkg"
name="ViconDataPublisher"
output="screen"
type="ViconDataPublisher"
>
<rosparam command="load" file="$(find dfall_pkg)/param/ViconConfig.yaml" />
</node>
</group>
<group if="$(arg emulateMocap)">
<node
pkg="dfall_pkg"
name="ViconDataPublisher"
output="screen"
type="MocapEmulator"
>
<rosparam command="load" file="$(find dfall_pkg)/param/MocapEmulatorConfig.yaml" />
</node>
</group>
</launch>
......@@ -11,7 +11,7 @@
<button
class="button-push navy fullwidth"
id="buttonRosMasterStatus"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('checkForRosMaster', 'rosMasterStatus', null, null)"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('checkForRosMaster', 'rosMasterStatus', ['rosLaunchMasterStatus','killMasterStatus'], null)"
>
Check for ROS Master
<div class="div-for-button-highlight-on-touchscreen navy"></div>
......@@ -27,7 +27,7 @@
<button
class="button-push navy fullwidth"
id="buttonLaunchRosMaster"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('launchRosMaster', 'rosLaunchMasterStatus', 'killMasterStatus', ['buttonRosMasterStatus','buttonRosAgentStatus','buttonRosNodeList'])"
onclick="roslaunch_outputLabelID_clearOtherLabels_clickOtherButtons('master', 'rosLaunchMasterStatus', ['rosMasterStatus','killMasterStatus'], ['buttonRosAgentStatus','buttonRosNodeList'])"
>
Launch ROS Master
<div class="div-for-button-highlight-on-touchscreen navy"></div>
......@@ -59,7 +59,7 @@
<button
class="button-push red fullwidth"
id="buttonKillRosMaster"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('killRosMaster', 'killMasterStatus', 'rosLaunchMasterStatus', ['buttonRosMasterStatus','buttonRosAgentStatus','buttonRosNodeList'])"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('killRosMaster', 'killMasterStatus', ['rosMasterStatus','rosLaunchMasterStatus'], ['buttonRosAgentStatus','buttonRosNodeList'])"
>
Kill ROS Master
<div class="div-for-button-highlight-on-touchscreen red"></div>
......@@ -83,7 +83,7 @@
<button
class="button-push navy fullwidth"
id="buttonRosAgentStatus"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('checkForRosAgent', 'rosAgentStatus', null, ['buttonRosMasterStatus','buttonRosNodeList'])"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('checkForRosAgent', 'rosAgentStatus', ['rosLaunchAgentStatus','killAgentStatus'], 'buttonRosNodeList')"
>
Check for ROS Agent
<div class="div-for-button-highlight-on-touchscreen navy"></div>
......@@ -99,7 +99,7 @@
<button
class="button-push navy fullwidth"
id="buttonLaunchRosAgent"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('launchRosAgent', 'rosLaunchAgentStatus', 'killAgentStatus', ['buttonRosMasterStatus','buttonRosAgentStatus','buttonRosNodeList'])"
onclick="roslaunch_outputLabelID_clearOtherLabels_clickOtherButtons('agent', 'rosLaunchAgentStatus', ['rosAgentStatus','killAgentStatus'], 'buttonRosNodeList')"
>
Launch ROS Agent
<div class="div-for-button-highlight-on-touchscreen navy"></div>
......@@ -131,7 +131,7 @@
<button
class="button-push red fullwidth"
id="buttonKillRosAgent"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('killRosAgent', 'killAgentStatus', 'rosLaunchAgentStatus', ['buttonRosMasterStatus','buttonRosAgentStatus','buttonRosNodeList'])"
onclick="callBashScript_outputLabelID_clearOtherLabels_clickOtherButtons('killRosAgent', 'killAgentStatus', ['rosAgentStatus','rosLaunchAgentStatus'], 'buttonRosNodeList')"
>
Kill ROS Agent
<div class="div-for-button-highlight-on-touchscreen red"></div>
......@@ -168,7 +168,7 @@
<table class="ros-table">
<tr>
<td class="ros-info-cell">
<td class="ros-info-cell" style="height:100px;vertical-align:text-top;">
<div id="rosnodeList"></div>
</td>
</tr>
......
......@@ -10,16 +10,16 @@ source /home/www-share/dfall/dfall-system/dfall_ws/src/dfall_pkg/launch/Config.s
# > Note: the -q options converts the
# grep output to a true/false
if rosnode list | grep -q /rosout; then
# Check that if the agent is already
# launched
if rosnode list | grep -q "$(printf "/dfall/agent%03d" $DFALL_DEFAULT_AGENT_ID)"; then
# Kill all nodes starting with
# /dfall/agentXXX/
rosnode list | grep "$(printf "/dfall/agent%03d" $DFALL_DEFAULT_AGENT_ID)" | xargs rosnode kill > /dev/null
echo "Agent $DFALL_DEFAULT_AGENT_ID killed"
else
echo "Agent $DFALL_DEFAULT_AGENT_ID not found"
fi
# Check that if the agent is already
# launched
if rosnode list | grep -q "$(printf "/dfall/agent%03d" $DFALL_DEFAULT_AGENT_ID)"; then
# Kill all nodes starting with
# /dfall/agentXXX/
rosnode list | grep "$(printf "/dfall/agent%03d" $DFALL_DEFAULT_AGENT_ID)" | xargs rosnode kill > /dev/null
echo "Agent $DFALL_DEFAULT_AGENT_ID killed"
else
echo "Agent $DFALL_DEFAULT_AGENT_ID not found"
fi
else
echo "ROS Master not found"
echo "ROS Master not found"
fi
#!/bin/bash
#
# Make the ROS commands available
# NOTE: these paths should NOT use ~
source /opt/ros/melodic/setup.bash
#source /home/www-share/dfall/dfall-system/dfall_ws/devel/setup.bash
source /home/www-share/dfall/dfall-system/dfall_ws/src/dfall_pkg/launch/Config.sh
#
# Check that the ROS Master exists
# > Note: the -q options converts the
# grep output to a true/false
if rosnode list | grep -q /rosout; then
# Kill all nodes
rosnode kill --all > /dev/null 2>&1 &
# The /rosout will respawn, so all kill any
# "roslaunch" process owned by the
# "www-data" user
pkill -u www-data roslaunch
# For debugging it is usefull to running the
# following commands on the server machine
# >> ps -aux
# >> pgrep -u www-data
# Inform the user
echo "Killed all ros nodes"
else
echo "ROS Master not found"
fi
#!/bin/bash
#
# Check that exactly one command is supplied
if [ "$#" -ne 1 ]; then
echo "exactly one argument must be supplied"
exit 1
fi
#
# Check that the first command supplied is valid
if [ "$1" != "true" ] && [ "$1" != "false" ]; then
echo "emulate crazyradio = $1, is not a valid boolean."
exit 1
fi
#
# Put the commands into variables for make things more readable
emulateradio=$1
#
# Make the ROS commands available
# NOTE: these paths should NOT use ~
source /opt/ros/melodic/setup.bash
......@@ -16,14 +31,14 @@ export ROS_LOG_DIR=/var/www/html/.ros/log
# > Note: the -q options converts the
# grep output to a true/false
if rosnode list | grep -q /rosout; then
# Check that if the agent is already
# launched
if rosnode list | grep -q "$(printf "/dfall/agent%03d" $DFALL_DEFAULT_AGENT_ID)"; then
echo "Agent $DFALL_DEFAULT_AGENT_ID is already running"
else
nohup roslaunch dfall_pkg agent.launch withGUI:=false emulateRadio:=true > /dev/null 2>&1 &
echo "Agent $DFALL_DEFAULT_AGENT_ID successfully launched"
fi
# Check that if the agent is already
# launched
if rosnode list | grep -q "$(printf "/dfall/agent%03d" $DFALL_DEFAULT_AGENT_ID)"; then
echo "Agent $DFALL_DEFAULT_AGENT_ID is already running"
else
nohup roslaunch dfall_pkg pi_agent.launch emulateRadio:=$emulateradio > /dev/null 2>&1 &
echo "Agent $DFALL_DEFAULT_AGENT_ID successfully launched"
fi
else
echo "ROS Master not found"
echo "ROS Master not found"
fi
#!/bin/bash
#
# Check that exactly one command is supplied
if [ "$#" -ne 1 ]; then
echo "exactly one argument must be supplied"
exit 1
fi
#
# Check that the first command supplied is valid
if [ "$1" != "true" ] && [ "$1" != "false" ]; then
echo "emulate mocap = $1, is not a valid boolean."
exit 1
fi
#
# Put the commands into variables for make things more readable
emultemocap=$1
#
# Make the ROS commands available
# NOTE: these paths should NOT use ~
source /opt/ros/melodic/setup.bash
source /home/www-share/dfall/dfall-system/dfall_ws/devel/setup.bash
source /home/www-share/dfall/dfall-system/dfall_ws/src/dfall_pkg/launch/Config.sh
#
# Set the ROS log location
export ROS_LOG_DIR=/var/www/html/.ros/log
#
# Mount the dfall workspace folder
#sudo mount --bind /home/pbeuchat/gitrep/dfall/dfall-system/dfall_ws /var/www/html/dfall_ws
#
# Check that the ROS Master exists
# > Note: the -q options converts the
# grep output to a true/false
if rosnode list | grep -q /rosout; then
echo "ROS Master is already running"
else
nohup roslaunch dfall_pkg pi_master.launch emulateMocap:=$emultemocap > /dev/null 2>&1 &
echo "ROS Master successfully launched"
fi
\ No newline at end of file
......@@ -2,13 +2,13 @@
#
# Check that exactly one command is supplied
if [ "$#" -ne 1 ]; then
echo "failed"
echo "exactly one argument must be supplied"
exit 1
fi
#
# Check that the command supplied is valid
if [ "$1" != "0" ] && [ "$1" != "1" ]; then
echo "failed"
echo "command = $1, is not a valid option"
exit 1
fi
#
......@@ -25,18 +25,25 @@ source /home/www-share/dfall/dfall-system/dfall_ws/src/dfall_pkg/launch/Config.s
# > Note: the -q options converts the
# grep output to a true/false
if rosnode list | grep -q /rosout; then
# Convert the agent ID to a zero padded string
agentnamespace=$(printf "agent%03d" $DFALL_DEFAULT_AGENT_ID)
# Send the message
if [ "$command" == "0" ]; then
temp="$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/FlyingAgentClient/crazyRadioCommand dfall_pkg/IntWithHeader '{data: 0, shouldCheckForAgentID: False}')"
# Convert the agent ID to a zero padded string
agentnamespace=$(printf "agent%03d" $DFALL_DEFAULT_AGENT_ID)
# Send the message
if [ "$command" == "0" ]; then
# Publish the request
temp="$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/FlyingAgentClient/CrazyRadioCommand dfall_pkg/IntWithHeader "{data: 0, shouldCheckForAgentID: False}")"
# Return that the message was sent
echo "sent"
#
elif [ "$command" == "1" ]; then
# Publish the request
temp="$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/FlyingAgentClient/CrazyRadioCommand dfall_pkg/IntWithHeader "{data: 1, shouldCheckForAgentID: False}")"
# Return that the message was sent
echo "sent"
else
# Return that the command is not recognised
echo "command = $command is not a valid option"
fi
if [ "$command" == "1" ]; then
temp="$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/FlyingAgentClient/crazyRadioCommand dfall_pkg/IntWithHeader '{data: 1, shouldCheckForAgentID: False}')"
fi
#
# Return that the message was sent
echo "sent"
else
echo "ROS Master not found"
echo "ROS Master not found"
fi
......@@ -2,13 +2,13 @@
#
# Check that exactly five commands are supplied
if [ "$#" -ne 5 ]; then
echo "failed"
echo "exaclty five arguments must be supplied"
exit 1
fi
#
# Check that the first command supplied is valid
if [ "$1" != "default" ] && [ "$1" != "student" ]; then
echo "failed"
echo "command = $1, is not a valid option."
exit 1
fi
#
......@@ -19,6 +19,28 @@ ynew=$3
znew=$4
yawnew=$5
#
# Check that the new setpoint values are purely numerical
# > For x:
if ! [[ $xnew =~ ^[+-]?[0-9]+\.?[0-9]*$ ]];then
echo "x = $xnew, is not a float."
exit 1
fi
# > For y:
if ! [[ $ynew =~ ^[+-]?[0-9]+\.?[0-9]*$ ]];then
echo "y = $ynew, is not a float."
exit 1
fi
# > For z:
if ! [[ $znew =~ ^[+-]?[0-9]+\.?[0-9]*$ ]];then
echo "z = $znew, is not a float."
exit 1
fi
# > For yaw:
if ! [[ $yawnew =~ ^[+-]?[0-9]+\.?[0-9]*$ ]];then
echo "yaw = $yawnew, is not a float."
exit 1
fi
#
# Make the ROS commands available
# NOTE: these paths should NOT use ~
source /opt/ros/melodic/setup.bash
......@@ -33,14 +55,21 @@ if rosnode list | grep -q /rosout; then
agentnamespace=$(printf "agent%03d" $DFALL_DEFAULT_AGENT_ID)
# Send the message
if [ "$command" == "default" ]; then
"$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/DefaultControllerService/RequestSetpointChange dfall_pkg/SetpointWithHeader "{x: $xnew, y: $ynew, z: $znew, yaw: $yawnew, shouldCheckForAgentID: False}")"
fi
if [ "$command" == "student" ]; then
"$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/StudentControllerService/RequestSetpointChange dfall_pkg/SetpointWithHeader "{x: $xnew, y: $ynew, z: $znew, yaw: $yawnew, shouldCheckForAgentID: False}")"
fi
# Publish the request
temp="$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/DefaultControllerService/RequestSetpointChange dfall_pkg/SetpointWithHeader "{x: $xnew, y: $ynew, z: $znew, yaw: $yawnew, shouldCheckForAgentID: False}")"
# Return that the message was sent
echo "sent"
#
elif [ "$command" == "student" ]; then
# Publish the request
temp="$(rostopic pub -1 /$ROS_NAMESPACE/$agentnamespace/StudentControllerService/RequestSetpointChange dfall_pkg/SetpointWithHeader "{x: $xnew, y: $ynew, z: $znew, yaw: $yawnew, shouldCheckForAgentID: False}")"
# Return that the message was sent
echo "sent"
#
# Return that the message was sent
echo "sent"
else
# Return that the command is not recognised
echo "controller = $command is not a valid option"
fi
else
echo "ROS Master not found"
......
......@@ -30,19 +30,25 @@
$temp = shell_exec("./bashscripts/catkin_make.sh");
$output = "<pre>$temp</pre>";
}
//
// For the LAUNCH tab
elseif ($scriptname == "checkForRosMaster") {
$output = shell_exec("./bashscripts/checkForRosMaster.sh");
}
elseif ($scriptname == "checkForRosAgent") {
$output = shell_exec("./bashscripts/checkForRosAgent.sh");
//
// "launch Ros Master" is handled separately
// because it requires an input argument
//
elseif ($scriptname == "killRosMaster") {
$output = shell_exec("./bashscripts/killRosMaster.sh");
}
elseif ($scriptname == "checkForRosAgent") {
$output = shell_exec("./bashscripts/checkForRosAgent.sh");
}
elseif ($scriptname == "launchRosAgent") {
$output = shell_exec("./bashscripts/launchRosAgent.sh");
}
//
// "launch Ros Agent" is handled separately
// because it requires an input argument
//
elseif ($scriptname == "killRosAgent") {
$output = shell_exec("./bashscripts/killRosAgent.sh");
}
......@@ -50,6 +56,7 @@
$temp = shell_exec("./bashscripts/rosnodeList.sh");
$output = "<pre>$temp</pre>";
}
//
// For the CONTROL tab:
// { RADIO CONNECTION, TAKE-OFF, LAND, MOTORS-OFF, LOAD CONTROLLER }
elseif ($scriptname == "rosConnect") {
......
<?php
// GET THE BASH SCRIPT NAME
$scriptname = $_GET['scriptname'];
// ONLY EXECUTE "SCRIPT NAMES" WITH AN EXACT MATCH
//
// > For the MASTER
if ($scriptname == "master")
{
// GET THE VALUES OF THE EMULATE MOCAP FLAG
// > This will be a string
$emulate_mocap = strtolower( $_GET['emulatemocap'] );
// Check that the new setpoint values are numerical
if (in_array($emulate_mocap, array("true", "1", "yes"), true))
{
$emulate_mocap = "true";
}
elseif (in_array($emulate_mocap, array("false", "0", "no"), true))
{
$emulate_mocap = "false";
}
else
{
echo "emulate mocap flag = $emulate_mocap, is not a boolean value.";
exit();
}
// Call the bash script for launching the master
$output = shell_exec("./bashscripts/launchRosMaster.sh $emulate_mocap");
}
//
// > For the AGENT
elseif ($scriptname == "agent")
{
// GET THE VALUES OF THE EMULATE MOCAP FLAG
// > This will be a string
$emulate_crazyradio = strtolower( $_GET['emulatecrazyradio'] );
// Check that the new setpoint values are numerical
if (in_array($emulate_crazyradio, array("true", "1", "yes"), true))
{
$emulate_crazyradio = "true";
}
elseif (in_array($emulate_crazyradio, array("false", "0", "no"), true))
{
$emulate_crazyradio = "false";
}
else
{
echo "emulate crazyradio flag = $emulate_crazyradio, is not a boolean value.";
exit();
}
// Call the bash script for launching the agent
$output = shell_exec("./bashscripts/launchRosAgent.sh $emulate_crazyradio");
}
else
{
$output = "launch name = $scriptname is not a valid option";