Set Up and Connect to CARLA Simulator
This example shows how to set up and connect to the CARLA simulator using ROS Toolbox to simulate autonomous driving applications.
You can utilise CARLA Simulator to replicate various driving scenarios spanning from urban to highway environments and evaluate the effectiveness of their autonomous driving algorithms in a controlled virtual environment. The simulator includes a variety of sensor models, vehicle dynamics, and traffic situations, allowing users to simulate real-world settings. You can use Simulink® software to send steering, braking, and throttle control signals to vehicle controls publisher and control the CARLA Ego vehicle and investigate various elements of autonomous driving.
Install the latest CARLA simulator on your Linux® host machine. If you are working on a Windows® machine, download and install the ROS Virtual Machine also. This virtual machine is based on the Ubuntu® Linux® operating system and is pre-configured to support applications built using ROS Toolbox.
This example is demonstrated on Windows® host machine.
Start CARLA Server
To start CARLA server on your Windows® host machine, navigate to the installed location of CARLA and click the application executable
Set Up CARLA ROS Bridge
Launch the virtual machine.
On the Ubuntu desktop, click the ROS Noetic Core Terminal shortcut to start the ROS master. Once the master is launched, note down the
On the Ubuntu desktop, click the ROS Noetic Terminal shortcut to start the ROS terminal. Run this command to setup the CARLA ROS bridge environment..
Launch Ego Vehicle Using CARLA Client
In the same terminal, run the
followcommand to launch the Ego vehicle in your preferred the environment of CARLA simulator. For example, you can run the
followcommand in Town03 environment of CARLA simulator to launch the vehicle near to the gas station.
Run this command to change the host address to the host address of your machine.
roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch host:=172.18.226.60 timeout:=60000 town:='Town03' spawn_point:=-25,-134,0.5,0,0,-90
Verify CARLA ROS Connection
Connect Simulink to the ROS master running in the VM Ware.
Verify that you can access ROS topics related to the CARLA simulator by running the following introspection command.