|
| 1 | +import os |
| 2 | +import launch |
| 3 | +from ament_index_python.packages import get_package_share_directory |
| 4 | + |
| 5 | +def generate_launch_description(): |
| 6 | + ld = launch.LaunchDescription([ |
| 7 | + # Basic launch arguments |
| 8 | + launch.actions.DeclareLaunchArgument( |
| 9 | + name='host', |
| 10 | + default_value='localhost' |
| 11 | + ), |
| 12 | + launch.actions.DeclareLaunchArgument( |
| 13 | + name='port', |
| 14 | + default_value='2000' |
| 15 | + ), |
| 16 | + launch.actions.DeclareLaunchArgument( |
| 17 | + name='timeout', |
| 18 | + default_value='10' |
| 19 | + ), |
| 20 | + launch.actions.DeclareLaunchArgument( |
| 21 | + name='role_name', |
| 22 | + default_value='ego_vehicle' |
| 23 | + ), |
| 24 | + launch.actions.DeclareLaunchArgument( |
| 25 | + name='vehicle_filter', |
| 26 | + default_value='vehicle.*' |
| 27 | + ), |
| 28 | + launch.actions.DeclareLaunchArgument( |
| 29 | + name='spawn_point', |
| 30 | + default_value='None' |
| 31 | + ), |
| 32 | + launch.actions.DeclareLaunchArgument( |
| 33 | + name='town', |
| 34 | + default_value='Town01' |
| 35 | + ), |
| 36 | + launch.actions.DeclareLaunchArgument( |
| 37 | + name='passive', |
| 38 | + default_value='False' |
| 39 | + ), |
| 40 | + launch.actions.DeclareLaunchArgument( |
| 41 | + name='synchronous_mode_wait_for_vehicle_control_command', |
| 42 | + default_value='False' |
| 43 | + ), |
| 44 | + launch.actions.DeclareLaunchArgument( |
| 45 | + name='fixed_delta_seconds', |
| 46 | + default_value='0.05' |
| 47 | + ), |
| 48 | + # Weather condition launch arguments |
| 49 | + launch.actions.DeclareLaunchArgument( |
| 50 | + name='cloudiness', |
| 51 | + default_value='30.0' # Default cloudiness level |
| 52 | + ), |
| 53 | + launch.actions.DeclareLaunchArgument( |
| 54 | + name='precipitation', |
| 55 | + default_value='30.0' # Default precipitation level |
| 56 | + ), |
| 57 | + launch.actions.DeclareLaunchArgument( |
| 58 | + name='sun_altitude_angle', |
| 59 | + default_value='10.0' # Default sun altitude angle |
| 60 | + ), |
| 61 | + launch.actions.DeclareLaunchArgument( |
| 62 | + name='sun_azimuth_angle', |
| 63 | + default_value='90.0' # Default sun azimuth angle |
| 64 | + ), |
| 65 | + launch.actions.DeclareLaunchArgument( |
| 66 | + name='precipitation_deposits', |
| 67 | + default_value='20.0' # Default precipitation deposits level |
| 68 | + ), |
| 69 | + launch.actions.DeclareLaunchArgument( |
| 70 | + name='wind_intensity', |
| 71 | + default_value='0.0' # Default wind intensity |
| 72 | + ), |
| 73 | + launch.actions.DeclareLaunchArgument( |
| 74 | + name='fog_density', |
| 75 | + default_value='1.0' # Default fog density |
| 76 | + ), |
| 77 | + launch.actions.DeclareLaunchArgument( |
| 78 | + name='wetness', |
| 79 | + default_value='0.0' # Default wetness level |
| 80 | + ), |
| 81 | + # Log weather information for debugging |
| 82 | + launch.actions.LogInfo( |
| 83 | + msg=['Cloudiness: ', launch.substitutions.LaunchConfiguration('cloudiness')] |
| 84 | + ), |
| 85 | + launch.actions.LogInfo( |
| 86 | + msg=['Precipitation: ', launch.substitutions.LaunchConfiguration('precipitation')] |
| 87 | + ), |
| 88 | + launch.actions.LogInfo( |
| 89 | + msg=['Sun Altitude Angle: ', launch.substitutions.LaunchConfiguration('sun_altitude_angle')] |
| 90 | + ), |
| 91 | + launch.actions.LogInfo( |
| 92 | + msg=['Sun Azimuth Angle: ', launch.substitutions.LaunchConfiguration('sun_azimuth_angle')] |
| 93 | + ), |
| 94 | + launch.actions.LogInfo( |
| 95 | + msg=['Precipitation Deposits: ', launch.substitutions.LaunchConfiguration('precipitation_deposits')] |
| 96 | + ), |
| 97 | + launch.actions.LogInfo( |
| 98 | + msg=['Wind Intensity: ', launch.substitutions.LaunchConfiguration('wind_intensity')] |
| 99 | + ), |
| 100 | + launch.actions.LogInfo( |
| 101 | + msg=['Fog Density: ', launch.substitutions.LaunchConfiguration('fog_density')] |
| 102 | + ), |
| 103 | + launch.actions.LogInfo( |
| 104 | + msg=['Wetness: ', launch.substitutions.LaunchConfiguration('wetness')] |
| 105 | + ), |
| 106 | + # Include the carla_ros_bridge launch file |
| 107 | + # Propagate both the basic and weather parameters. |
| 108 | + launch.actions.IncludeLaunchDescription( |
| 109 | + launch.launch_description_sources.PythonLaunchDescriptionSource( |
| 110 | + os.path.join(get_package_share_directory('carla_ros_bridge'), |
| 111 | + 'carla_ros_bridge.launch.py') |
| 112 | + ), |
| 113 | + launch_arguments={ |
| 114 | + 'host': launch.substitutions.LaunchConfiguration('host'), |
| 115 | + 'port': launch.substitutions.LaunchConfiguration('port'), |
| 116 | + 'town': launch.substitutions.LaunchConfiguration('town'), |
| 117 | + 'timeout': launch.substitutions.LaunchConfiguration('timeout'), |
| 118 | + 'passive': launch.substitutions.LaunchConfiguration('passive'), |
| 119 | + 'synchronous_mode_wait_for_vehicle_control_command': launch.substitutions.LaunchConfiguration('synchronous_mode_wait_for_vehicle_control_command'), |
| 120 | + 'fixed_delta_seconds': launch.substitutions.LaunchConfiguration('fixed_delta_seconds'), |
| 121 | + # Pass weather parameters to carla_ros_bridge (if supported) |
| 122 | + 'cloudiness': launch.substitutions.LaunchConfiguration('cloudiness'), |
| 123 | + 'precipitation': launch.substitutions.LaunchConfiguration('precipitation'), |
| 124 | + 'sun_altitude_angle': launch.substitutions.LaunchConfiguration('sun_altitude_angle'), |
| 125 | + 'sun_azimuth_angle': launch.substitutions.LaunchConfiguration('sun_azimuth_angle'), |
| 126 | + 'precipitation_deposits': launch.substitutions.LaunchConfiguration('precipitation_deposits'), |
| 127 | + 'wind_intensity': launch.substitutions.LaunchConfiguration('wind_intensity'), |
| 128 | + 'fog_density': launch.substitutions.LaunchConfiguration('fog_density'), |
| 129 | + 'wetness': launch.substitutions.LaunchConfiguration('wetness') |
| 130 | + }.items() |
| 131 | + ), |
| 132 | + # Include the carla_spawn_objects launch file |
| 133 | + launch.actions.IncludeLaunchDescription( |
| 134 | + launch.launch_description_sources.PythonLaunchDescriptionSource( |
| 135 | + os.path.join(get_package_share_directory('carla_spawn_objects'), |
| 136 | + 'carla_example_ego_vehicle.launch.py') |
| 137 | + ), |
| 138 | + launch_arguments={ |
| 139 | + 'host': launch.substitutions.LaunchConfiguration('host'), |
| 140 | + 'port': launch.substitutions.LaunchConfiguration('port'), |
| 141 | + 'timeout': launch.substitutions.LaunchConfiguration('timeout'), |
| 142 | + 'vehicle_filter': launch.substitutions.LaunchConfiguration('vehicle_filter'), |
| 143 | + 'role_name': launch.substitutions.LaunchConfiguration('role_name'), |
| 144 | + 'spawn_point': launch.substitutions.LaunchConfiguration('spawn_point') |
| 145 | + }.items() |
| 146 | + ), |
| 147 | + # Include the carla_manual_control launch file |
| 148 | + launch.actions.IncludeLaunchDescription( |
| 149 | + launch.launch_description_sources.PythonLaunchDescriptionSource( |
| 150 | + os.path.join(get_package_share_directory('carla_manual_control'), |
| 151 | + 'carla_manual_control.launch.py') |
| 152 | + ), |
| 153 | + launch_arguments={ |
| 154 | + 'role_name': launch.substitutions.LaunchConfiguration('role_name') |
| 155 | + }.items() |
| 156 | + ) |
| 157 | + ]) |
| 158 | + return ld |
| 159 | + |
| 160 | +if __name__ == '__main__': |
| 161 | + generate_launch_description() |
| 162 | + |
0 commit comments