Repository: ros/ros_comm

Issue:
roslaunch sorted and more verbose output
Migrated from https://code.ros.org/trac/ros/ticket/3905
Reported by:    kruset  Owned by:   kwc
Priority:   minor 
Attachment available: No
Last modified ago: Apr 2012

---

Hi,

working on navigation I notice the output of roslaunch could be improved IMO:

```
$ roslaunch navigation_stage move_base_amcl_10cm.launch
PARAMETERS
 * /use_sim_time
 * /move_base_node/global_costmap/observation_sources
 * /amcl/gui_publish_rate
 * /move_base_node/local_costmap/origin_y
```

The parameter list is not sorted and does not tell the parameters. i know you can get the parameters with --dump-params, but for that you need to run the roslaunch command in another shell, which can be a hassle, or stop that launch and start again (hassle again). I see no benefit in not showing the param values by default.

So I suggest both sorting outputs and showing params. Diff rosinstall/config.py:

```
@@ -222,11 +223,11 @@
         """
         summary = '\nSUMMARY\n========'
         if self.clear_params:
-            summary += '\n\nCLEAR PARAMETERS\n' + '\n'.join([' * %s'%p for p in self.clear_params])
+            summary += '\n\nCLEAR PARAMETERS\n' + '\n'.join(sorted([' * %s'%p for p in self.clear_params]))
         if self.params:
-            summary += '\n\nPARAMETERS\n' + '\n'.join([' * %s'%k for k in self.params])
+            summary += '\n\nPARAMETERS\n' + '\n'.join(sorted([' * %s  \t%s'%(k, v.value) for k, v in self.params.items()]))
         if not local:
-            summary += '\n\nMACHINES\n' + '\n'.join([' * %s'%k for k in self.machines if k])
+            summary += '\n\nMACHINES\n' + '\n'.join(sorted([' * %s'%k for k in self.machines if k]))
         summary += '\n\nNODES\n'
         namespaces = {}
         if local:
@@ -240,7 +241,7 @@
             else:
                 namespaces[ns].append(n)
         for k,v in namespaces.iteritems():
-            summary += '  %s\n'%k + '\n'.join(['    %s'%_summary_name(n) for n in v])
+            summary += '  %s\n'%k + '\n'.join(sorted(['    %s'%_summary_name(n) for n in v]))
             summary += '\n'
         return summary
```

Result:

```
$ roslaunch navigation_stage move_base_amcl_10cm.launch
...
PARAMETERS
 * /amcl/gui_publish_rate       10.0
 * /amcl/kld_err        0.05
 * /amcl/kld_z          0.99
 * /amcl/laser_lambda_short     0.1
```

Also I notice dump-params produces very ugly output for floats:

```
/amcl/odom_alpha1: 0.20000000000000001
/amcl/odom_alpha2: 0.20000000000000001
/amcl/odom_alpha3: 0.80000000000000004
/amcl/odom_alpha4: 0.20000000000000001
```

Not sure where that comes from, not sure how to fix it.



Discussion:
Content of trimmed_valus.patch

```
224 224         if self.clear_params: 
225 225             summary += '\n\nCLEAR PARAMETERS\n' + '\n'.join(sorted([' * %s'%p for p in self.clear_params])) 
226 226         if self.params: 
227                 summary += '\n\nPARAMETERS\n' + '\n'.join(sorted([' * %s'%k for k in self.params])) 
    227             def trim(longstring): 
    228                 return longstring[:20] + (longstring[20:] and '..') 
    229             params_and_values = sorted([' * %s  \t%s'%(k, trim(str(v.value))) for k, v in self.params.items()]) 
    230             summary += '\n\nPARAMETERS\n' + '\n'.join(params_and_values) 
228 231         if not local: 
229 232             summary += '\n\nMACHINES\n' + '\n'.join(sorted([' * %s'%k for k in self.machines if k])) 
230 233         summary += '\n\nNODES\n' 
```

Changed 10 months ago by kruset

And if I may add, a good additional information for dump-params would be to indicate the source of the param value, so that the user can easily change that if he is unhappy.
Changed 9 months ago by kwc

```
status changed from new to closed
resolution set to fixed
```

r16624

Thanks for the patch. I did not include the display of parameter values. While useful, parameter values are frequently entire calibration files. It is also possible to put binary values on the parameter server. The value would need better trimming in order to not overrun the display in these cases.

In the future, please always attach patches as files. It is an extra hassle to deal with inline comment diffs.
Changed 9 months ago by kruset

```
attachment trimmed_valus.patch Download added
```

Changed 9 months ago by kruset

```
status changed from closed to reopened
resolution fixed deleted
```

How about the attached patch for trimming the value?

The sorting has been implemented a long ago.

PR #397 adds printing of trimmed / filtered values.


Resolving patch:
diff --git a/tools/roslaunch/src/roslaunch/config.py b/tools/roslaunch/src/roslaunch/config.py
--- a/tools/roslaunch/src/roslaunch/config.py
+++ b/tools/roslaunch/src/roslaunch/config.py
@@ -229,7 +229,17 @@ def summary(self, local=False):
         if self.clear_params:
             summary += '\n\nCLEAR PARAMETERS\n' + '\n'.join(sorted([' * %s'%p for p in self.clear_params]))
         if self.params:
-            summary += '\n\nPARAMETERS\n' + '\n'.join(sorted([' * %s'%k for k in self.params]))
+            def strip_string(value):
+                max_length = 20
+                if len(value) > max_length:
+                    value = value[:max_length - 3] + '...'
+                # if non printable characters are present return replacement
+                for char in value:
+                    i = ord(char)
+                    if i < 32 or i > 126:
+                        return '<...>'
+                return value
+            summary += '\n\nPARAMETERS\n' + '\n'.join(sorted([' * %s: %s' % (k, strip_string(str(v.value))) for k, v in self.params.items()]))
         if not local:
             summary += '\n\nMACHINES\n' + '\n'.join(sorted([' * %s'%k for k in self.machines if k]))
         summary += '\n\nNODES\n'


Test patch: