<launch>

	<!-- INPUT ARGUMENT OF THE AGENT's ID -->
	<arg name="agentID" default="$(optenv DFALL_DEFAULT_AGENT_ID)" />

	<!-- INPUT ARGUMENT FOR LAUNCHING A GUI OR NOT -->
	<arg name="withGUI" default="true" />

	<!-- 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 d_fall_pps agentID:=1 -->

    <group ns="$(eval 'agent' + str(agentID).zfill(3))">

		<!-- 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>

		<!-- STUDENT CONTROLLER -->
		<node
			pkg    = "d_fall_pps"
			name   = "StudentControllerService"
			output = "screen"
			type   = "StudentControllerService"
			>
		</node>

		<!-- MPC CONTROLLER -->
		<node
			pkg    = "d_fall_pps"
			name   = "MpcControllerService"
			output = "screen"
			type   = "MpcControllerService"
			>
		</node>

		<!-- REMOTE CONTROLLER -->
		<node
			pkg    = "d_fall_pps"
			name   = "RemoteControllerService"
			output = "screen"
			type   = "RemoteControllerService"
			>
		</node>

		<!-- TUNING CONTROLLER -->
		<node
			pkg    = "d_fall_pps"
			name   = "TuningControllerService"
			output = "screen"
			type   = "TuningControllerService"
			>
		</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/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"
			/>
		</node>


		<!-- AGENT GUI (aka. the "student GUI") -->
		<group if="$(arg withGUI)">
			<node
				pkg    = "d_fall_pps"
				name   = "student_GUI"
				output = "screen"
				type   = "student_GUI">
			</node>
		</group>
		
	</group>

</launch>