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 8 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
55 changes: 55 additions & 0 deletions simulator/CARLA_Autoware/carla_autoware/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.8)
project(carla_autoware)

find_package(autoware_cmake REQUIRED)
autoware_package()

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

Check warning on line 3 in simulator/CARLA_Autoware/carla_autoware/README.md

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (ROS2)

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

Check warning on line 5 in simulator/CARLA_Autoware/carla_autoware/README.md

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (ROS2)

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)

Check warning on line 7 in simulator/CARLA_Autoware/carla_autoware/README.md

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (ROS2)

- 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/)

Check warning on line 25 in simulator/CARLA_Autoware/carla_autoware/README.md

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (containts)
1. Download maps (y-axis inverted version) to arbitaly location

Check warning on line 26 in simulator/CARLA_Autoware/carla_autoware/README.md

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (arbitaly)
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",

Check warning on line 20 in simulator/CARLA_Autoware/carla_autoware/config/objects.json

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (opendrive)
"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",

Check warning on line 62 in simulator/CARLA_Autoware/carla_autoware/config/objects.json

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (opendrive)
"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,13 @@
<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">
<remap from="/points_raw" to="/sensing/lidar/top/outlier_filtered/pointcloud"/>
<remap from="/points_raw" to="/sensing/lidar/concatenated/pointcloud"/>
</node>
</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="30"/>
<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>
37 changes: 37 additions & 0 deletions simulator/CARLA_Autoware/carla_autoware/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<package format="3">
<name>carla_autoware</name>
<version>0.0.0</version>
<description>The carla_manual_control package</description>
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
<maintainer email="mradityagio@gmail.com">CARLA Simulator Team</maintainer>
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
<license>MIT</license>
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved

<exec_depend>ros2launch</exec_depend>
<exec_depend>ros_compatibility</exec_depend>
<exec_depend>std_msgs</exec_depend>
<depend>astuff_sensor_msgs</depend>
<depend>autoware_auto_control_msgs</depend>
<depend>autoware_auto_vehicle_msgs</depend>
<depend>carla_data_provider</depend>
<depend>carla_msgs</depend>
<depend>datetime</depend>
<depend>geometry_msgs</depend>
<depend>math</depend>
<depend>nav_msgs</depend>
<depend>numpy</depend>
<depend>rclpy</depend>
<depend>sensor_msgs</depend>
<depend>sensor_msgs_py</depend>
<depend>tf2</depend>
<depend>tf2_ros</depend>
<depend>transform3d</depend>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
mraditya01 marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
4 changes: 4 additions & 0 deletions simulator/CARLA_Autoware/carla_autoware/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/carla_autoware
[install]
install_scripts=$base/lib/carla_autoware
Loading
Loading