Repository: ros/ros_comm

Issue:
roslaunch opening .launch file encoding error
My launch file has UTF-8 encoding.
When I run "roslaunch server.launch" it fails with message:

'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)



Discussion:
Please post you launch file as an example which can be used to reproduce the issue.

```
<?xml version="1.0" encoding="UTF-8"?>
<launch>
  <!--  <node name="s_play" pkg="sound_play" type="soundplay_node.py"/> 
    <node name="speaking" pkg="smart_home_speech" type="speaking_node.py">
        <param name="mapfile" value="$(find smart_home_speech)/share/russian.map"/>
    </node>
-->
    <node name="notification" pkg="smart_home_core" type="notification_node.py">
        <param name="mail_to" value="aleksey.shipulya@gmail.com"/>
        <param name="smtp_user" value="aleksey.shipulya"/>
        <param name="smtp_password" value=""/>
    </node>
    <node name="server" pkg="smart_home_core" type="command_server.py"/>
    <node name="rosserial" pkg="rosserial_python" type="serial_node.py">
        <param name="port" value="/dev/ttyACM0"/>
    </node>

    <!-- sensors -->
    <node name="leak_sensor_kitchen" pkg="smart_home_sensors" type="bit_sensor.py">
        <param name="sensor_id" value="/mnt/1wire/12.5BF53D000000/sensed.A"/>
        <param name="check_interval" value="300"/>
    </node>
    <node name="leak_sensor_kitchen_notif" pkg="smart_home_sensors" type="sensor_notifier_node.py">
        <param name="sensor_topic" value="/leak_sensor_kitchen"/>
        <param name="notification_text" value="Внимание! Сработал датчик протечки на кухне"/>
        <param name="criteria" value="eq"/>
        <param name="notification_value" value="False"/>
        <param name="notification_target" value="log,voice,mail,sms"/>
    </node>

    <node name="leak_sensor_toilet" pkg="smart_home_sensors" type="bit_sensor.py">
        <param name="sensor_id" value="/mnt/1wire/12.86F03D000000/sensed.A"/>
        <param name="check_interval" value="300"/>
    </node>
    <node name="leak_sensor_toilet_notif" pkg="smart_home_sensors" type="sensor_notifier_node.py">
        <param name="sensor_topic" value="/leak_sensor_toilet"/>
        <param name="notification_text" value="Внимание! Сработал датчик протечки в туалете!"/>
        <param name="criteria" value="eq"/>
        <param name="notification_value" value="False"/>
        <param name="notification_target" value="log,voice,mail,sms"/>
    </node>

    <node name="leak_sensor_bath" pkg="smart_home_sensors" type="bit_sensor.py">
        <param name="sensor_id" value="/mnt/1wire/12.AEF33D000000/sensed.A"/>
        <param name="check_interval" value="300"/>
    </node>
    <node name="leak_sensor_bath_notif" pkg="smart_home_sensors" type="sensor_notifier_node.py">
        <param name="sensor_topic" value="/leak_sensor_bath"/>
        <param name="notification_text" value="Внимание! Сработал датчик протечки в ванной!"/>
        <param name="criteria" value="eq"/>
        <param name="notification_value" value="False"/>
        <param name="notification_target" value="log,voice,mail,sms"/>
    </node>
    <node name="humidity_low_notif" pkg="smart_home_sensors" type="sensor_notifier_node.py">
        <param name="sensor_topic" value="/avr_humidity"/>
        <param name="criteria" value="lt"/>
        <param name="notification_value" value="35"/>
        <param name="notification_level" value="1"/>
        <param name="notification_target" value="log,voice"/>
        <param name="notification_text" value="Низкая влажность воздуха! %value% процентов"/>
        <param name="interval" value="3600"/>
    </node>
    <node name="humidity_hi_notif" pkg="smart_home_sensors" type="sensor_notifier_node.py">
        <param name="sensor_topic" value="/avr_humidity"/>
        <param name="criteria" value="gt"/>
        <param name="notification_level" value="1"/>
        <param name="notification_value" value="65"/>
        <param name="notification_target" value="log,voice"/>
        <param name="notification_text" value="Высокая влажность воздуха! %value% процентов"/>
        <param name="interval" value="3600"/>
    </node>
<!--
    <node name="webcam" pkg="usb_cam" type="usb_cam_node">
        <param name="pixel_format" value="yuyv"/>
        <param name="image_width" value="320"/>
        <param name="image_height" value="240"/>
    </node>
    <node name="mjpeg_server" pkg="mjpeg_server" type="mjpeg_server"/>
    -->
</launch>
```


Resolving patch:
diff --git a/tools/roslaunch/src/roslaunch/__init__.py b/tools/roslaunch/src/roslaunch/__init__.py
--- a/tools/roslaunch/src/roslaunch/__init__.py
+++ b/tools/roslaunch/src/roslaunch/__init__.py
@@ -288,10 +288,14 @@ def main(argv=sys.argv):
 
     except RLException as e:
         roslaunch_core.printerrlog(str(e))
+        roslaunch_core.printerrlog('The traceback for the exception was written to the log file')
+        logger.error(traceback.format_exc())
         sys.exit(1)
     except ValueError as e:
         # TODO: need to trap better than this high-level trap
         roslaunch_core.printerrlog(str(e))
+        roslaunch_core.printerrlog('The traceback for the exception was written to the log file')
+        logger.error(traceback.format_exc())
         sys.exit(1)
     except Exception as e:
         traceback.print_exc()
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
@@ -234,6 +234,11 @@ def summary(self, local=False):
             summary += '\n\nCLEAR PARAMETERS\n' + '\n'.join(sorted([' * %s'%p for p in self.clear_params]))
         if self.params:
             def strip_string(value):
+                # not dealing with non-ascii characters here
+                try:
+                    value = str(value)
+                except UnicodeEncodeError:
+                    return '<...>'
                 max_length = 20
                 if len(value) > max_length:
                     value = value[:max_length - 3] + '...'
@@ -247,7 +252,7 @@ def strip_string(value):
                             break
                         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()]))
+            summary += '\n\nPARAMETERS\n' + '\n'.join(sorted([' * %s: %s' % (k, strip_string(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: