SlideShare a Scribd company logo
1 of 36
CARLA
PYTHON AI MODULE
SALOM JERLIN
TRAINER HEAD
HITAKEY TECH SOLUTION PVT LTD
DATE: 5/10/23 10 AM
VENUE: PERIYAR UNIVERSITY,Salem
9790072449
INTRODUCTION
: CARLA simulator is a platform which is developed to support the development, training, and
validation of autonomous “self-driving” systems.
This simulation helps to detect and diagnose autonomous self-driving systems in the virtual
world. By using CARLA, we are able to see our model work in the virtual world and train them to
get ready for the real world.
In this simulated world, we can provide obstacles just like the real world which help to learn
more about real world scenarios for the system.
Simulator:
A simulator is a machine or a program which is designed to provide a realistic imitation of real
life situations.
Basically, it controls and operates the behavior of a vehicle, aircraft, or other complex systems
of the virtual environment.
In this case, CARLA simulates a dynamic world and provides a simple interface between the
world and an agent that interacts with the world.
Environment:
: It is a computer simulated virtual world which consists of actors and communication between
them.
For example, the city or the town environment that we see in car racing or bike racing video
games.
Sensors:
: We all have electronic devices which widely contain a different type of sensor.
A sensor is a device or subsystem whose purpose is to detect events or changes in its
environment and send the information.
A sensor is nothing but a device just like we have in phones which shows direction just like a
GPS/compass. Example: GyroscopE
CARLA SENSORS
Camera sensor - to detect the images of the environment
A Depth sensor - to detect the distance of spaces from top, bottom, front, or back of the object.
A Radar sensor - to detect or track the position of an object based on its distances etc
So, we can now say that self-driving cars rely on sensors to navigate
CARLA SET UP
1.OPEN CMD PROMPT AND TYPE
conda
Check conda is installed??
If yes I will open the folder which I had extracted after downloading CARLA, which is
WindowsNoEditor
2.CLICK ADDRESSBAR AND TYPE CMD
3.open the command prompt window
Create a new environment
Here you need to create an environment to run carla programs.
For that use the below command.
conda create -n name of environment python==3.7 -y
conda create -n self_driving_car python==3.7 -y
Activate the environment
Then we will activate our environment,
Syntax: activate (name of your environment)
Code: activate self_driving_car
Environment is running.
Install libraries
pip install --user gamepy numpy
pip install carla
Run carla
TYPE CarlaUE4
PRESS ENTER
You can see Carla environment
CarlaUE4 –quality—level=Low
W A S D E keys
Spawn some cars
Type cd PythonAPI
Type cd examples
Type python spawn_npc.py –n 100
How to write simple program
Step 1
Set up your environment: seen earlier
Step 2
Install virtual environment
python –m venv name_of_env
Example python –m venv virtual_env
continue
Step3 ACTIVATE ENVIRONMENT
.nameScriptsactivate
Step4 INSTALL PACKAGES
pip install –r requirements.txt
******RUN ANY PROGRAM*****
How to write a simple program
Import necessary libraries:
In your Python script, import the necessary CARLA modules and any additional libraries
you may need.
import carla
import time
Required settings
Copy and paste the settings upto line 16
Structure of the program
try:
finally:
print("destroying actors")
for actor in actor_list:
actor.destroy()
print("done")
Connect to the CARLA server
Connect to the CARLA server using the provided host and port. You can specify the host
and port as needed.
try:
client = carla.Client('localhost', 2000)
client.set_timeout(2.0) # Set a timeout for connection (2 seconds in
this example).
Load a map and create a world:
Load a CARLA map and create a world object to interact with the simulation
environment.
world = client.get_world()
Get blueprint of the vehicle
Craete actor list on top
actor_list = []
#get to blueprint
blueprint_library=world.get_blueprint_library()
bp=blueprint_library.filter("model3")[0]
Or
Set spawn point
vehicle_transform = (world.get_map().get_spawn_points())
spawn_point=random.choice(world.get_map().get_spawn_points())
Or
spawn_point=random.choice(vehicle_transform)
Spawn the vehicle
You can spawn a vehicle at a specific location in the simulation world. You'll need to
define the vehicle's blueprint (e.g., a specific car model) and transform (position and
orientation).
vehicle = world.spawn_actor(bp, spawn_point)
vehicle.set_autopilot(True)(if needs)
spawn_point = carla.Transform(carla.Location(x=10, y=10, z=2), carla.Rotation(pitch=0, yaw=0,
roll=0))
Control the vehicle:
You can control the vehicle's movements using various commands. For example, to
make the vehicle move forward:
vehicle.apply_control(carla.VehicleControl(throttle=1.0,steer=0.0))
Add vehicle
#add vehicle
actor_list.append(vehicle)
After done
finally:
print("destroying actors")
for actor in actor_list:
actor.destroy()
print("done")
Run the simulation:
Start the simulation loop and allow the program to run for a specified duration or until a
specific condition is met.
try:
# Add your simulation logic here.
time.sleep(10) # Run the simulation for 10 seconds in this example.
finally:
vehicle.destroy()
Cleanup:
Always remember to clean up resources by destroying the objects you've spawned in
the simulation, like the vehicle.
Run script
Always run the script in cmd panel
python scriptname.py
Change the view
simulator_camera_location_rotation = carla.Transform(spawn_point.location, spawn_point.rotation)
simulator_camera_location_rotation.location += spawn_point.get_forward_vector() * 30
simulator_camera_location_rotation.rotation.yaw += 180
simulator_camera_view = world.get_spectator()
simulator_camera_view.set_transform(simulator_camera_location_rotation)
vehicle.set_transform(spawn_point)
Atatch camera sensor
#sensor
blueprint=blueprint_library.find("sensor.camera.rgb")
blueprint.set_attribute("image_size_x",f"{IM_WIDTH}")
blueprint.set_attribute("image_size_y",f"{IM_HEIGHT}")
blueprint.set_attribute("fov","110")
Spawn sensor
spawn_point=carla.Transform(carla.Location(x=2.5, z=0.7))
sensor=world.spawn_actor(blueprint,spawn_point,attach_to=vehicle)
actor_list.append(sensor)
Do something
sensor.listen(lambda data:process_img(data))
Image function
def process_img(image):
i=np.array(image.raw_data)
i2=i.reshape((IM_HEIGHT,IM_WIDTH,4))
i3=i2[:,:,:3]
cv2.imshow("",i3)
cv2.waitKey(1)
return i3/255.0
change vehicle
1.Run the Carla file simple_Carla1.py car will be moving
Python simple_Carla1.py –no—-autopilot stop the car
python simple_Carla1.py –filter vehicle.bmw.grandtourer -no--
autopilot
Spawn at different place
Find this line
vehicle_transform = (world.get_map().get_spawn_points()[1])
Give any spawn point from 1 to 200
Run the file again
Lets create a variable
location_for_vehicle=world.get_map().get_spawn_points()
vehicle_transform = random.choice(location_for_vehicle)
Title Lorem Ipsum
LOREM IPSUM DOLOR SIT AMET,
CONSECTETUER ADIPISCING ELIT.
NUNC VIVERRA IMPERDIET ENIM.
FUSCE EST. VIVAMUS A TELLUS.
PELLENTESQUE HABITANT MORBI
TRISTIQUE SENECTUS ET NETUS.

More Related Content

Similar to carla advanced Artificial Intelligence module

EclipseCon 2009: TmL Tutorial Exercises
EclipseCon 2009: TmL Tutorial ExercisesEclipseCon 2009: TmL Tutorial Exercises
EclipseCon 2009: TmL Tutorial ExercisesEric Cloninger
 
Application of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptx
Application of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptxApplication of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptx
Application of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptxMohammadAbdullah1811
 
Aerodynamics analysis around_a_car_by_cfd
Aerodynamics analysis around_a_car_by_cfdAerodynamics analysis around_a_car_by_cfd
Aerodynamics analysis around_a_car_by_cfds1160120
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleMarian Wamsiedel
 
IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...
IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...
IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...IRJET Journal
 
Reinforcement Learning for Self Driving Cars
Reinforcement Learning for Self Driving CarsReinforcement Learning for Self Driving Cars
Reinforcement Learning for Self Driving CarsSneha Ravikumar
 
R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?Villu Ruusmann
 
Public class race track {public static void main(string[] args
Public class race track {public static void main(string[] argsPublic class race track {public static void main(string[] args
Public class race track {public static void main(string[] argsYASHU40
 
Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder paramisoft
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Controlbhochhi
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...Andrey Karpov
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | javaRajesh Kumar
 
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdfBOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdfMichaelOLeary82
 

Similar to carla advanced Artificial Intelligence module (20)

EclipseCon 2009: TmL Tutorial Exercises
EclipseCon 2009: TmL Tutorial ExercisesEclipseCon 2009: TmL Tutorial Exercises
EclipseCon 2009: TmL Tutorial Exercises
 
Application of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptx
Application of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptxApplication of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptx
Application of Simulation Modeling-Mohammad Abdullah-181-15-2051-PC-B .pptx
 
Aerodynamics analysis around_a_car_by_cfd
Aerodynamics analysis around_a_car_by_cfdAerodynamics analysis around_a_car_by_cfd
Aerodynamics analysis around_a_car_by_cfd
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical example
 
State Monad
State MonadState Monad
State Monad
 
Java getstarted
Java getstartedJava getstarted
Java getstarted
 
IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...
IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...
IRJET-Survey on Simulation of Self-Driving Cars using Supervised and Reinforc...
 
Reinforcement Learning for Self Driving Cars
Reinforcement Learning for Self Driving CarsReinforcement Learning for Self Driving Cars
Reinforcement Learning for Self Driving Cars
 
2 oop
2 oop2 oop
2 oop
 
R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?
 
Public class race track {public static void main(string[] args
Public class race track {public static void main(string[] argsPublic class race track {public static void main(string[] args
Public class race track {public static void main(string[] args
 
Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Control
 
java tr.docx
java tr.docxjava tr.docx
java tr.docx
 
Simulating TUM Drone 2.0 by ROS
Simulating TUM Drone 2.0  by ROSSimulating TUM Drone 2.0  by ROS
Simulating TUM Drone 2.0 by ROS
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | java
 
FLAR Workflow
FLAR WorkflowFLAR Workflow
FLAR Workflow
 
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdfBOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
 

Recently uploaded

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Recently uploaded (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

carla advanced Artificial Intelligence module

  • 1. CARLA PYTHON AI MODULE SALOM JERLIN TRAINER HEAD HITAKEY TECH SOLUTION PVT LTD DATE: 5/10/23 10 AM VENUE: PERIYAR UNIVERSITY,Salem 9790072449
  • 2. INTRODUCTION : CARLA simulator is a platform which is developed to support the development, training, and validation of autonomous “self-driving” systems. This simulation helps to detect and diagnose autonomous self-driving systems in the virtual world. By using CARLA, we are able to see our model work in the virtual world and train them to get ready for the real world. In this simulated world, we can provide obstacles just like the real world which help to learn more about real world scenarios for the system.
  • 3. Simulator: A simulator is a machine or a program which is designed to provide a realistic imitation of real life situations. Basically, it controls and operates the behavior of a vehicle, aircraft, or other complex systems of the virtual environment. In this case, CARLA simulates a dynamic world and provides a simple interface between the world and an agent that interacts with the world.
  • 4. Environment: : It is a computer simulated virtual world which consists of actors and communication between them. For example, the city or the town environment that we see in car racing or bike racing video games.
  • 5. Sensors: : We all have electronic devices which widely contain a different type of sensor. A sensor is a device or subsystem whose purpose is to detect events or changes in its environment and send the information. A sensor is nothing but a device just like we have in phones which shows direction just like a GPS/compass. Example: GyroscopE
  • 6. CARLA SENSORS Camera sensor - to detect the images of the environment A Depth sensor - to detect the distance of spaces from top, bottom, front, or back of the object. A Radar sensor - to detect or track the position of an object based on its distances etc So, we can now say that self-driving cars rely on sensors to navigate
  • 7. CARLA SET UP 1.OPEN CMD PROMPT AND TYPE conda Check conda is installed?? If yes I will open the folder which I had extracted after downloading CARLA, which is WindowsNoEditor 2.CLICK ADDRESSBAR AND TYPE CMD 3.open the command prompt window
  • 8. Create a new environment Here you need to create an environment to run carla programs. For that use the below command. conda create -n name of environment python==3.7 -y conda create -n self_driving_car python==3.7 -y
  • 9. Activate the environment Then we will activate our environment, Syntax: activate (name of your environment) Code: activate self_driving_car Environment is running.
  • 10. Install libraries pip install --user gamepy numpy pip install carla
  • 11. Run carla TYPE CarlaUE4 PRESS ENTER You can see Carla environment CarlaUE4 –quality—level=Low W A S D E keys
  • 12. Spawn some cars Type cd PythonAPI Type cd examples Type python spawn_npc.py –n 100
  • 13. How to write simple program Step 1 Set up your environment: seen earlier Step 2 Install virtual environment python –m venv name_of_env Example python –m venv virtual_env
  • 14. continue Step3 ACTIVATE ENVIRONMENT .nameScriptsactivate Step4 INSTALL PACKAGES pip install –r requirements.txt ******RUN ANY PROGRAM*****
  • 15. How to write a simple program Import necessary libraries: In your Python script, import the necessary CARLA modules and any additional libraries you may need. import carla import time
  • 16. Required settings Copy and paste the settings upto line 16
  • 17. Structure of the program try: finally: print("destroying actors") for actor in actor_list: actor.destroy() print("done")
  • 18. Connect to the CARLA server Connect to the CARLA server using the provided host and port. You can specify the host and port as needed. try: client = carla.Client('localhost', 2000) client.set_timeout(2.0) # Set a timeout for connection (2 seconds in this example).
  • 19. Load a map and create a world: Load a CARLA map and create a world object to interact with the simulation environment. world = client.get_world()
  • 20. Get blueprint of the vehicle Craete actor list on top actor_list = [] #get to blueprint blueprint_library=world.get_blueprint_library() bp=blueprint_library.filter("model3")[0] Or
  • 21. Set spawn point vehicle_transform = (world.get_map().get_spawn_points()) spawn_point=random.choice(world.get_map().get_spawn_points()) Or spawn_point=random.choice(vehicle_transform)
  • 22. Spawn the vehicle You can spawn a vehicle at a specific location in the simulation world. You'll need to define the vehicle's blueprint (e.g., a specific car model) and transform (position and orientation). vehicle = world.spawn_actor(bp, spawn_point) vehicle.set_autopilot(True)(if needs) spawn_point = carla.Transform(carla.Location(x=10, y=10, z=2), carla.Rotation(pitch=0, yaw=0, roll=0))
  • 23. Control the vehicle: You can control the vehicle's movements using various commands. For example, to make the vehicle move forward: vehicle.apply_control(carla.VehicleControl(throttle=1.0,steer=0.0))
  • 25. After done finally: print("destroying actors") for actor in actor_list: actor.destroy() print("done")
  • 26. Run the simulation: Start the simulation loop and allow the program to run for a specified duration or until a specific condition is met. try: # Add your simulation logic here. time.sleep(10) # Run the simulation for 10 seconds in this example. finally: vehicle.destroy()
  • 27. Cleanup: Always remember to clean up resources by destroying the objects you've spawned in the simulation, like the vehicle.
  • 28. Run script Always run the script in cmd panel python scriptname.py
  • 29. Change the view simulator_camera_location_rotation = carla.Transform(spawn_point.location, spawn_point.rotation) simulator_camera_location_rotation.location += spawn_point.get_forward_vector() * 30 simulator_camera_location_rotation.rotation.yaw += 180 simulator_camera_view = world.get_spectator() simulator_camera_view.set_transform(simulator_camera_location_rotation) vehicle.set_transform(spawn_point)
  • 34. change vehicle 1.Run the Carla file simple_Carla1.py car will be moving Python simple_Carla1.py –no—-autopilot stop the car python simple_Carla1.py –filter vehicle.bmw.grandtourer -no-- autopilot
  • 35. Spawn at different place Find this line vehicle_transform = (world.get_map().get_spawn_points()[1]) Give any spawn point from 1 to 200 Run the file again Lets create a variable location_for_vehicle=world.get_map().get_spawn_points() vehicle_transform = random.choice(location_for_vehicle)
  • 36. Title Lorem Ipsum LOREM IPSUM DOLOR SIT AMET, CONSECTETUER ADIPISCING ELIT. NUNC VIVERRA IMPERDIET ENIM. FUSCE EST. VIVAMUS A TELLUS. PELLENTESQUE HABITANT MORBI TRISTIQUE SENECTUS ET NETUS.