How to comment a ROS launch file

How to comment a ROS launch file

I am always forgetting how to have a nested comments in a ROS launch file, so I’m putting this information here in the hope to reduce my time searching on Google.

The Problem

I often have a large launch file with multiple comments in it so I can recall what each parameter do. Here is the file that was causing me some troubles:

<!--
This launch file is an example for 3D registration using DSO stero reconstruction

-->

<launch>
	<node name="mapper" type="dynamic_mapper" pkg="ethzasl_icp_mapper" output="screen">
		<remap from="cloud_in" to="/csv_to_pc2/pointcloud" />
		<param name="subscribe_scan" value="false" />
		<param name="subscribe_cloud" value="true" />
		<param name="icpConfig" value="$(find ethzasl_icp_mapper)/launch/kingfisher/DSO/icp.yaml" />
		<param name="inputFiltersConfig" value="$(find ethzasl_icp_mapper)/launch/kingfisher/DSO/input_filters.yaml" />
		<param name="mapPostFiltersConfig" value="$(find ethzasl_icp_mapper)/launch/kingfisher/DSO/map_post_filters.yaml" />
		<param name="odom_frame" value="/pointcloud" />
		<param name="map_frame" value="/map" />
		<param name="useROSLogger" value="true" />
		<param name="minOverlap" value="0.1" /> 
		<param name="maxOverlapToMerge" value="0.85" /> 
		<param name="minMapPointCount" value="500" /> 
		<param name="minReadingPointCount" value="30" /> 

		<!-- Parameters for dynamic elements -->
		<param name="priorStatic" value="0.45"/>
		<param name="priorDyn" value="0.55"/>
		<param name="maxAngle" value="0.1"/>
		<param name="eps_a" value="0.004"/><!--1 deg = 0.017rad-->
		<param name="eps_d" value="0.005"/>
		<param name="alpha" value="0.99"/>
		<param name="beta" value="0.90"/>
		<param name="maxDyn" value="0.90"/>

		<param name="maxDistNewPoint" value="0.1"/>
		<param name="sensorMaxRange" value="20.0"/>


	</node>

	<node pkg="tf" type="static_transform_publisher" name="correction_tf" args="0 0 0 0 0.2 0 /pointcloud /boat_level 100"/>

</launch>

If I want to comment the node <node name="mapper">, the typical block comment <!-- --> will break because of the nested comment <!--1 deg = 0.017rad-->. So much, that even the syntax highlight used for this web site will not render it properly:

<launch>
	<!--node name="mapper" type="dynamic_mapper" pkg="ethzasl_icp_mapper" output="screen">
		<param name="eps_a" value="0.004"/><!--1 deg = 0.017rad-->
	</node-->

	<node pkg="tf" type="static_transform_publisher" name="correction_tf" args="0 0 0 0 0.2 0 /pointcloud /boat_level 100"/>

</launch>

Solution

Using the non-existing processing-instruction <?ignore <stuff> ?> will solve the problem and all the tags in between won’t be parsed and only the node <tf> will start:

<launch>
	<?ignore
	<node name="mapper" type="dynamic_mapper" pkg="ethzasl_icp_mapper" output="screen">
		<param name="eps_a" value="0.004"/><!--1 deg = 0.017rad-->
	</node>
	?>

	<node pkg="tf" type="static_transform_publisher" name="correction_tf" args="0 0 0 0 0.2 0 /pointcloud /boat_level 100"/>
</launch>