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
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ repos:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
hooks:
- id: markdownlint
args: [-c, .markdownlint.yaml, --fix]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.6
hooks:
Expand Down
22 changes: 22 additions & 0 deletions simulator/carla_autoware/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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()

ament_export_dependencies(rclpy)

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


ament_auto_package(
launch
resource
src
)
ament_package()
68 changes: 68 additions & 0 deletions simulator/carla_autoware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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.15-ubuntu-22.04).
- Install .whl using pip.

# Environment

| ubuntu | ros | carla | autoware |
| :----: | :----: | :----: | :-------------: |
| 22.04 | humble | 0.9.15 | 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/)
- [Carla Lanelet2 Maps](https://bitbucket.org/carla-simulator/autoware-contents/src/master/maps/)
- [Carla Sensor Kit](https://github.com/mraditya01/carla_sensor_kit_launch)
- [Autoware Individual params (forked with CARLA Sensor Kit params)](https://github.com/mraditya01/autoware_individual_params)
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 for CARLA ros-bridge on ROS2 Humble.

```
git clone --recurse-submodules https://github.com/mraditya01/carla_ros_bridge.git
```

## 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 -RenderOffScreen
```

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 simulator_type:=carla
```

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.
- Simulation time somtimes slowed down to 0.9x realtime.
92 changes: 92 additions & 0 deletions simulator/carla_autoware/config/objects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"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": "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": 480,
"image_size_y": 360,
"fov": 90.0
},
{
"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": 64,
"points_per_second": 480000,
"upper_fov": 3.0,
"lower_fov": -27.0,
"rotation_frequency": 20,
"noise_stddev": 0.0
},
{
"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.pseudo.tf",
"id": "tf"
},
{
"type": "sensor.pseudo.objects",
"id": "objects"
},
{
"type": "sensor.pseudo.odom",
"id": "odometry"
},
{
"type": "actor.pseudo.control",
"id": "control"
}
]
}
]
}
6 changes: 6 additions & 0 deletions simulator/carla_autoware/launch/carla_autoware.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<launch>
<group>
<node pkg="carla_autoware" exec="carla_autoware" name="carla_autoware" output="screen"/>
<node pkg="tf2_ros" exec="static_transform_publisher" name="ego_vehicle2base_link" args="0 0 0 0 0 0 /ego_vehicle /base_link "/>
</group>
</launch>
49 changes: 49 additions & 0 deletions simulator/carla_autoware/launch/carla_ros.launch.xml
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.1"/>
<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']"/>

<!-- CARLA Object Definition Location -->
<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)"/>
<!-- Remap -->
<remap from="/carla/ego_vehicle/lidar" to="/sensing/lidar/top/outlier_filtered/pointcloud"/>
<remap from="/carla/ego_vehicle/imu" to="/sensing/imu/tamagawa/imu_raw"/>
<remap from="/carla/ego_vehicle/rgb_front/image" to="/sensing/camera/traffic_light/image_raw"/>
<remap from="/carla/ego_vehicle/rgb_front/camera_info" to="/sensing/camera/traffic_light/camera_info"/>
</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>
</launch>
37 changes: 37 additions & 0 deletions simulator/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 autoware bridge package</description>
<maintainer email="mradityagio@gmail.com">Muhammad Raditya Giovanni</maintainer>
<maintainer email="maxime.clement@tier4.jp">Maxime CLEMENT</maintainer>
<license>Apache License 2.0</license>

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

<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>
Empty file.
4 changes: 4 additions & 0 deletions simulator/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
42 changes: 42 additions & 0 deletions simulator/carla_autoware/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from glob import glob
import os

ROS_VERSION = int(os.environ["ROS_VERSION"])

if ROS_VERSION == 1:
from distutils.core import setup

from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(packages=["carla_autoware"], package_dir={"": "src"})

setup(**d)

elif ROS_VERSION == 2:
from setuptools import setup

package_name = "carla_autoware"

setup(
name=package_name,
version="0.0.0",
packages=[package_name],
data_files=[
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
("share/" + package_name, glob("config/objects.json")),
("share/" + package_name, ["package.xml"]),
(os.path.join("share", package_name), glob("launch/carla_autoware.launch.xml")),
(os.path.join("share", package_name), glob("launch/carla_ros.launch.xml")),
],
install_requires=["setuptools"],
zip_safe=True,
maintainer="mradityagio",
maintainer_email="mradityagio@gmail.com",
description="CARLA ROS2 bridge for AUTOWARE",
license="Apache License 2.0",
tests_require=["pytest"],
entry_points={
"console_scripts": ["carla_autoware = carla_autoware.carla_autoware:main"],
},
package_dir={"": "src"},
)
Loading
Loading