Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(carla_autoware): add interface to easily use CARLA with Autoware #6621

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions simulator/CARLA_Autoware/carla_autoware/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.8)
project(carla_autoware)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()



# find dependencies
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(sensor_msgs_py REQUIRED)
find_package(datetime REQUIRED)

find_package(rclpy REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(carla_msgs REQUIRED)
find_package(autoware_auto_vehicle_msgs REQUIRED)
find_package(autoware_auto_control_msgs REQUIRED)
find_package(tier4_debug_msgs REQUIRED)
find_package(tier4_system_msgs REQUIRED)
find_package(autoware_adapi_v1_msgs REQUIRED)
find_package(transform3d REQUIRED)
find_package(math REQUIRED)
find_package(numpy REQUIRED)
find_package(carla_data_provider REQUIRED)




find_package(ros_environment REQUIRED)
set(ROS_VERSION $ENV{ROS_VERSION})

mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
ament_export_dependencies(rclpy)

# Install launch files.
install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/)


ament_auto_package(
launch
resource
src
)
ament_package()
69 changes: 69 additions & 0 deletions simulator/CARLA_Autoware/carla_autoware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# CARLA_Autoware

# ROS2/Autoware.universe bridge for CARLA simulator

### Thanks to <https://github.com/gezp> for ROS2 Humble support for CARLA ROS bridge

This ros package enables autonomous driving using Autoware in addition to the basic function of the official [ros-bridge](https://github.com/carla-simulator/ros-bridge) package (communication between ros and carla). (<https://github.com/gezp> for ROS2 Humble)

- Make sure to Download the Python egg for 3.10 from [here](https://github.com/gezp/carla_ros/releases/tag/carla-0.9.14-ubuntu-22.04).
- Add the egg file to the folder: ../CARLA_0.9.14/PythonAPI/carla/dist
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
- And install the wheel using pip.

# Environment

| ubuntu | ros | carla | autoware |
| :----: | :----: | :----: | :-------------: |
| 22.04 | humble | 0.9.14 | universe/master |

# Setup

## install

- [Autoware.Universe](https://autowarefoundation.github.io/autoware-documentation/galactic/installation/autoware/source-installation/)
- [CARLA Installation](https://carla.readthedocs.io/en/latest/start_quickstart/)
- [autoware containts](https://bitbucket.org/carla-simulator/autoware-contents/src/master/maps/)
1. Download maps (y-axis inverted version) to arbitaly location
2. Change names. (point_cloud/Town01.pcd -> Town01/pointcloud_map.pcd, vector_maps/lanelet2/Town01.osm -> Town01/lanelet2_map.osm)
3. Create `map_projector_info.yaml` and add `projector_type: local` on the first line.
- Clone this repositories and ROSBridge

```
git clone https://github.com/mraditya01/CARLA_Autoware.git
git clone --recurse-submodules https://github.com/gezp/carla_ros.git -b humble-carla-0.9.14
```
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved

- Copy the files (sensor_kit_calibration.yaml, sensors.calibration.yaml) from folder "GNSS_interface/src/carla_sensor_kit_launch/carla_sensor_kit_description/config" to "src/param/autoware_individual_params/carla_sensor_kit".
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved

## build

```bash
cd colcon_ws
colcon build --symlink-install
```

# Run

1. Run carla, change map, spawn object if you need

```bash
cd CARLA
./CarlaUE4.sh -prefernvidia -quality-level=Low
```

2. Run ros nodes

```bash
ros2 launch carla_autoware e2e_simulator.launch.xml map_path:=$HOME/autoware_map/carla_town_01 vehicle_model:=sample_vehicle sensor_model:=carla_sensor_kit
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
```

3. Set initial pose (Init by GNSS)
4. Set goal position
5. Wait for planning
6. Engage

# Tips

- If you want to edit the sensors configuration used in CARLA, edit `objects.json` located in `carla_autoware/config`.
- You will also need to edit the `carla_sensor_kit_description` if you change the sensor configuration.
- Misalignment might occurs during initialization, pressing `init by gnss` button should fix it.
125 changes: 125 additions & 0 deletions simulator/CARLA_Autoware/carla_autoware/config/objects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"objects": [
{
"type": "sensor.pseudo.traffic_lights",
"id": "traffic_lights"
},
{
"type": "sensor.pseudo.objects",
"id": "objects"
},
{
"type": "sensor.pseudo.actor_list",
"id": "actor_list"
},
{
"type": "sensor.pseudo.markers",
"id": "markers"
},
{
"type": "sensor.pseudo.opendrive_map",
"id": "map"
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
},
{
"type": "vehicle.toyota.prius",
"id": "ego_vehicle",
"sensors": [
{
"type": "sensor.camera.rgb",
"id": "rgb_front",
"spawn_point": { "x": 0.7, "y": 0.0, "z": 1.6, "roll": 0.0, "pitch": 0.0, "yaw": 0.0 },
"image_size_x": 1280,
"image_size_y": 720,
"fov": 100.0
},
{
"type": "sensor.camera.rgb",
"id": "rgb_view",
"spawn_point": { "x": -4.5, "y": 0.0, "z": 2.8, "roll": 0.0, "pitch": 20.0, "yaw": 0.0 },
"image_size_x": 800,
"image_size_y": 600,
"fov": 90.0,
"attached_objects": [
{
"type": "actor.pseudo.control",
"id": "control"
}
]
},
{
"type": "sensor.lidar.ray_cast",
"id": "lidar",
"spawn_point": { "x": 0.0, "y": 0.0, "z": 2.6, "roll": 0.0, "pitch": 0.0, "yaw": 0.0 },
"range": 50,
"channels": 32,
"points_per_second": 320000,
"upper_fov": 2.0,
"lower_fov": -26.8,
"rotation_frequency": 20,
"noise_stddev": 0.0
},
{
"type": "sensor.opendrive_map",
"id": "OpenDRIVE",
"spawn_point": { "x": 0.0, "y": 0.0, "z": 1.6, "roll": 0.0, "pitch": 0.0 }
},
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved

{
"type": "sensor.other.gnss",
"id": "gnss",
"spawn_point": { "x": 0.0, "y": 0.0, "z": 1.6 },
"noise_alt_stddev": 0.0,
"noise_lat_stddev": 0.0,
"noise_lon_stddev": 0.0,
"noise_alt_bias": 0.0,
"noise_lat_bias": 0.0,
"noise_lon_bias": 0.0
},
{
"type": "sensor.other.imu",
"id": "imu",
"spawn_point": { "x": 0.0, "y": 0.0, "z": 1.6, "roll": 0.0, "pitch": 0.0, "yaw": 0.0 },
"noise_accel_stddev_x": 0.0,
"noise_accel_stddev_y": 0.0,
"noise_accel_stddev_z": 0.0,
"noise_gyro_stddev_x": 0.0,
"noise_gyro_stddev_y": 0.0,
"noise_gyro_stddev_z": 0.0,
"noise_gyro_bias_x": 0.0,
"noise_gyro_bias_y": 0.0,
"noise_gyro_bias_z": 0.0
},
{
"type": "sensor.other.collision",
"id": "collision",
"spawn_point": { "x": 0.0, "y": 0.0, "z": 0.0 }
},
{
"type": "sensor.other.lane_invasion",
"id": "lane_invasion",
"spawn_point": { "x": 0.0, "y": 0.0, "z": 0.0 }
},
{
"type": "sensor.pseudo.tf",
"id": "tf"
},
{
"type": "sensor.pseudo.objects",
"id": "objects"
},
{
"type": "sensor.pseudo.odom",
"id": "odometry"
},
{
"type": "sensor.pseudo.speedometer",
"id": "speedometer"
},
{
"type": "actor.pseudo.control",
"id": "control"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<launch>
<group>
<node pkg="carla_autoware" exec="carla_autoware" name="carla_autoware" output="screen"/>
<node pkg="topic_tools" exec="relay" name="camera_info" args="/carla/ego_vehicle/rgb_front/camera_info /sensing/camera/traffic_light/camera_info"/>
<node pkg="topic_tools" exec="relay" name="camera" args="/carla/ego_vehicle/rgb_front/image /sensing/camera/camera5/image_rect_color"/>
<node pkg="tf2_ros" exec="static_transform_publisher" name="ego_vehicle2base_link" args=" 0 0 0 0 0 0 /ego_vehicle /base_link "/>
<node pkg="carla_gnss_interface" exec="carla_gnss_interface_node" name="carla_gnss_interface" output="screen"/>
<node pkg="carla_pointcloud_interface" exec="carla_pointcloud_interface_node" name="carla_pointcloud_interface" output="screen"/>
</group>
</launch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<launch>
<arg name="host" default="localhost"/>
<arg name="port" default="2000"/>
<arg name="timeout" default="10"/>
<arg name="role_name" default="ego_vehicle"/>
<arg name="vehicle_filter" default="vehicle.*"/>
<arg name="spawn_point" default="None"/>
<arg name="town" default="Town01"/>
<arg name="passive" default="False"/>
<arg name="synchronous_mode" default="True"/>
<arg name="synchronous_mode_wait_for_vehicle_control_command" default="False"/>
<arg name="fixed_delta_seconds" default="0.05"/>
<arg name="role_name" default="ego_vehicle"/>
<arg name="spawn_point_ego_vehicle" default="None"/>
<arg name="spawn_sensors_only" default="False"/>
<arg name="control_id" default="control"/>
<arg name="register_all_sensors" default="True"/>
<arg name="ego_vehicle_role_name" default="['hero', 'ego_vehicle', 'hero0', 'hero1', 'hero2', 'hero3', 'hero4', 'hero5', 'hero6', 'hero7', 'hero8', 'hero9']"/>

<arg name="objects_definition_file" default="$(find-pkg-share carla_autoware)/objects.json"/>

<node pkg="carla_ros_bridge" exec="bridge" name="carla_ros_bridge" output="screen">
<!-- Parameters -->
<param name="use_sim_time" value="true"/>
<param name="host" value="$(var host)"/>
<param name="port" value="$(var port)"/>
<param name="timeout" value="$(var timeout)"/>
<param name="passive" value="$(var passive)"/>
<param name="synchronous_mode" value="$(var synchronous_mode)"/>
<param name="synchronous_mode_wait_for_vehicle_control_command" value="$(var synchronous_mode_wait_for_vehicle_control_command)"/>
<param name="fixed_delta_seconds" value="$(var fixed_delta_seconds)"/>
<param name="town" value="$(var town)"/>
<param name="register_all_sensors" value="$(var register_all_sensors)"/>
<param name="ego_vehicle_role_name" value="$(var ego_vehicle_role_name)"/>
</node>

<node pkg="carla_spawn_objects" exec="carla_spawn_objects" name="carla_spawn_objects" output="screen">
<!-- Parameters -->
<param name="objects_definition_file" value="$(var objects_definition_file)"/>
<param name="spawn_point_ego_vehicle" value="$(var spawn_point_ego_vehicle)"/>
<param name="spawn_sensors_only" value="$(var spawn_sensors_only)"/>
</node>

<node pkg="carla_spawn_objects" exec="set_initial_pose" name="set_initial_pose" output="screen">
<!-- Parameters -->
<param name="role_name" value="$(var role_name)"/>
<param name="control_id" value="$(var control_id)"/>
</node>
</launch>
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<!-- Essential parameters -->
<arg name="map_path" description="point cloud and lanelet2 map directory path"/>
<arg name="vehicle_model" description="vehicle model name"/>
<arg name="sensor_model" description="sensor model name"/>
<arg name="data_path" default="$(env HOME)/autoware_data" description="packages data and artifacts directory path"/>
<arg name="carla" default="false" description="simulation used"/>

<!-- launch module preset -->
<arg name="planning_module_preset" default="default" description="planning module preset"/>

<!-- Optional parameters -->
<!-- Modules to be launched -->
<arg name="vehicle" default="true" description="launch vehicle"/>
<arg name="system" default="true" description="launch system"/>
<arg name="map" default="true" description="launch map"/>
<arg name="sensing" default="true" description="launch sensing"/>
<arg name="localization" default="true" description="launch localization"/>
<arg name="perception" default="true" description="launch perception"/>
<arg name="planning" default="true" description="launch planning"/>
<arg name="control" default="true" description="launch control"/>

<!-- Map -->
<arg name="lanelet2_map_file" default="lanelet2_map.osm" description="lanelet2 map file name"/>
<arg name="pointcloud_map_file" default="pointcloud_map.pcd" description="pointcloud map file name"/>
<!-- Perception -->
<arg name="traffic_light_namespace" default="traffic_light" description="traffic light recognition namespace1"/>
<!-- Control -->
<!-- Vehicle -->
<arg name="launch_vehicle_interface" default="false"/>
<!-- System -->
<arg name="launch_system_monitor" default="false" description="launch system monitor"/>
<arg name="launch_dummy_diag_publisher" default="false" description="launch dummy diag publisher"/>

<!-- Tools -->
<arg name="rviz" default="true" description="launch rviz"/>
<arg name="rviz_config" default="$(find-pkg-share autoware_launch)/rviz/autoware.rviz" description="rviz config"/>

<arg name="rviz_config" default="$(find-pkg-share autoware_launch)/rviz/autoware.rviz" description="rviz config"/>

<group if="$(var carla)">
<include file="$(find-pkg-share carla_autoware)/carla_ros.launch.xml"/>
<include file="$(find-pkg-share carla_autoware)/carla_autoware.launch.xml"/>
</group>

<group scoped="false">
<include file="$(find-pkg-share autoware_launch)/launch/autoware.launch.xml">
<!-- Common -->
<arg name="map_path" value="$(var map_path)"/>
<arg name="vehicle_model" value="$(var vehicle_model)"/>
<arg name="sensor_model" value="$(var sensor_model)"/>
<arg name="data_path" value="$(var data_path)"/>
<!-- launch module preset -->
<arg name="planning_module_preset" value="$(var planning_module_preset)"/>
<!-- Modules to be launched -->
<arg name="launch_vehicle" value="$(var vehicle)"/>
<arg name="launch_map" value="$(var map)"/>
<arg name="launch_sensing" value="$(var sensing)"/>
<arg name="launch_localization" value="$(var localization)"/>
<arg name="launch_perception" value="$(var perception)"/>
<arg name="launch_planning" value="$(var planning)"/>
<arg name="launch_control" value="$(var control)"/>
<!-- Global parameters -->
<arg name="use_sim_time" value="true"/>
<!-- Vehicle -->
<arg name="launch_vehicle_interface" value="$(var launch_vehicle_interface)"/>
<!-- Map -->
<arg name="lanelet2_map_file" value="$(var lanelet2_map_file)"/>
<arg name="pointcloud_map_file" value="$(var pointcloud_map_file)"/>
<!-- System -->
<arg name="launch_system_monitor" value="$(var launch_system_monitor)"/>
<arg name="launch_dummy_diag_publisher" value="$(var launch_dummy_diag_publisher)"/>
<!-- Sensing -->
<arg name="launch_sensing_driver" value="false"/>
<!-- Perception-->
<arg name="traffic_light_recognition/enable_fine_detection" value="false"/>
<arg name="namespace1" value="$(var traffic_light_namespace)"/>
<!-- Tools -->
<arg name="rviz" value="$(var rviz)"/>
<arg name="rviz_config" value="$(var rviz_config)"/>
</include>
</group>
</launch>
Loading
Loading