carla-simulator / ros-bridge

ROS bridge for CARLA Simulator
MIT License
513 stars 414 forks source link

Remove empty launch args default_value #622

Closed FelipeGdM closed 2 years ago

FelipeGdM commented 2 years ago

This PR fixes a bug found in foxy and newer distros that crashes the ROS 2 launch system when an argument with default_value='' is not overwritten. For some reason the empty string is internally converted to None, which raises the following error

File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/utilities/evaluate_parameters.py", line 95, in evaluate_parameter_dict
    raise TypeError(
TypeError: Allowed value types are bytes, bool, int, float, str, Sequence[bool], Sequence[int], 
Sequence[float], Sequence[str]. Got <class 'NoneType'>. If the parameter is meant to be a string, 
try wrapping it in launch_ros.parameter_descriptions.ParameterValue(value, value_type=str)

Similar problems can be found https://github.com/introlab/rtabmap_ros/issues/725, https://github.com/LORD-MicroStrain/ntrip_client/pull/16 and https://github.com/microsoft/Azure_Kinect_ROS_Driver/issues/246

The easiest solution is to replace the empty string with a non-empty string. When an invalid spawn-point is passed, the node issues the following warning and then informs that a random spawn point was chosen

[WARN] [carla_spawn_objects]: Invalid spawnpoint 'None'
[INFO] [carla_spawn_objects]: Spawn point selected at random

If a spawn point is specified in the object description, the system issues the warnings

[WARN] [carla_spawn_objects]: Invalid spawnpoint 'None'
[WARN] [carla_spawn_objects]: ego_vehicle: Could not use spawn point from parameters, the spawn point from config file will be used.

After this messages, the launch system proceeds normally

This PR solves the problem described in #603, even without explicit goal of Carla 0.9.13 support. I believe that it is highly likely that people trying to run the newest Carla version are also running the newest version of ROS 2, thus facing the error described here. Personally, I was able to run ros bridge with Carla 0.9.13 smoothly after this fix.


This change is Reviewable