Note: This tutorial assumes that you have completed the previous tutorials: Creating a PSENscan application package.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

How to configure parameters with yaml

Description: Introduction how to store your application's parameters persistently with a yaml-file.

Keywords: PSENscan, psen_scan

Tutorial Level: BEGINNER

Next Tutorial: Launching multiple scanners

Storing the parameters

Navigate to your catkin workspace

cd ~/catkin_ws/src/psen_scan_tutorials

Create a new directory where the yaml-file will go and navigate into it.

mkdir config
cd config

Create a new yaml-file with your favorite editor.

gedit config.yaml

Fill the yaml-file with key: value pairs that match the parameters you would like to store. Here ́s an example:

https://raw.githubusercontent.com/PilzDE/pilz_tutorials/master/psen_scan_tutorials/config/config.yaml

password: "ac0d68d033"
sensor_ip: "192.168.0.10"
host_ip: "192.168.0.25"
host_udp_port: 55000

Note: The four parameters password, sensor_ip, host_ip and host_udp_port are always required. You can't omit them. For the rest of the parameters and their explanation please refer to our ROS API.

Note: The parameter password has to be specified in an encrypted format. The above password can be used as default.

Save the file and navigate up a folder, then create a launch directory and navigate into it

cd ..
mkdir launch
cd launch

Create a new launch-file with your favorite editor

gedit psen_scan.launch

Here ́s an example launch-file:

https://raw.githubusercontent.com/PilzDE/pilz_tutorials/master/psen_scan_tutorials/launch/psen_scan.launch

<launch>
  <node name="laser_scanner" type="psen_scan_node" pkg="psen_scan" output="screen" required="true">
    <rosparam command="load" file="$(find psen_scan_tutorials)/config/config.yaml" />
  </node>
  <node name="rviz" type="rviz" pkg="rviz" args="-d $(find psen_scan)/config/config.rviz" />
</launch>

The code explained:

  <node name="laser_scanner" type="psen_scan_node" pkg="psen_scan" output="screen" required="true">
    <rosparam command="load" file="$(find psen_scan_tutorials)/config/config.yaml" />
  </node>

This starts the psen_scan_node and passes it the newly created config file.

  <node name="rviz" type="rviz" pkg="rviz" args="-d $(find psen_scan)/config/config.rviz" />

This starts rviz with a predefined configuration.

Start the PSENscan application

Setup the network of the host accordingly. Connect the PSENscan laser scanner to the network and to the power source. Enter the following to start RVIZ together with the ROS-Node for the PSENscan application.

roslaunch psen_scan_tutorials psen_scan.launch

Wiki: psen_scan/Tutorials/ConfiguringPsenScanParametersWithYaml (last edited 2020-01-29 12:29:42 by GSansone)