# ros2 launch: argument 'my_arg': expected type 'int' but got 'string'

- **ID:** `ros2/launch-argument-type-mismatch`
- **Domain:** ros2
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Launch file declares a launch argument with a specific type (e.g., LaunchConfiguration('my_arg', data_type='int')) but the user passes a string value on the command line or via a launch file that cannot be implicitly converted.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| ROS2 Humble | active | — | — |
| ROS2 Iron | active | — | — |
| ROS2 Jazzy | active | — | — |

## Workarounds

1. **Ensure the argument is passed without quotes: 'ros2 launch my_pkg my_launch.py my_arg:=5' (not 'my_arg:="5"'). If using a YAML file, specify the value as an integer (e.g., 'my_arg: 5').** (95% success)
   ```
   Ensure the argument is passed without quotes: 'ros2 launch my_pkg my_launch.py my_arg:=5' (not 'my_arg:="5"'). If using a YAML file, specify the value as an integer (e.g., 'my_arg: 5').
   ```
2. **Modify the launch file to accept a string and convert it to int inside the launch file using Python's int() function: 'int(LaunchConfiguration('my_arg'))'.** (90% success)
   ```
   Modify the launch file to accept a string and convert it to int inside the launch file using Python's int() function: 'int(LaunchConfiguration('my_arg'))'.
   ```

## Dead Ends

- **Adding quotes around the integer value (e.g., 'ros2 launch my_pkg my_launch.py my_arg:=5' becomes 'my_arg:="5"')** — Quotes force the value to be a string, which is exactly what causes the type mismatch. (90% fail)
- **Changing the launch file to remove type checking entirely** — Type checking is a safety feature; removing it may cause runtime errors if downstream nodes expect a specific type. (40% fail)
