Skip to content

Commit 7bf66d0

Browse files
Merge pull request #4 from codeness0/main
Update README.md
2 parents e43a88b + 721e7f1 commit 7bf66d0

File tree

1 file changed

+43
-35
lines changed

1 file changed

+43
-35
lines changed

README.md

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -99,67 +99,75 @@ Open up the simulator and make sure it's running correctly as you run it.
9999
![Image of Connection](http://avisengine.com/wp-content/uploads/2021/01/Screen-Shot-2021-01-25-at-1.01.41-AM.png)
100100

101101
### Python
102-
Go to the files you downloaded before. Open up Example.py
102+
Go to the files you downloaded before. Open up example.py
103103

104104
``` python
105-
# Compatible with AVIS Engine version 1.0.3 or higher
106-
import AVISEngine
105+
'''
106+
@ 2023, Copyright AVIS Engine
107+
- An Example Compatible with AVISEngine version 2.0.1 or higher
108+
'''
109+
import avisengine
110+
import config
107111
import time
108112
import cv2
109113

110-
#Calling the class
111-
car = AVISEngine.car()
114+
# Creating an instance of the Car class
115+
car = avisengine.Car()
112116

113-
#connecting to the server (Simulator)
114-
car.connect("127.0.0.1", 25001)
117+
# Connecting to the server (Simulator)
118+
car.connect(config.SIMULATOR_IP, config.SIMULATOR_PORT)
115119

116-
#Counter variable
120+
# Counter variable
117121
counter = 0
118122

119-
debug_mode = True
120-
#sleep for 2 seconds to make sure that client connected to the simulator
121-
time.sleep(2)
123+
debug_mode = False
124+
125+
# Sleep for 3 seconds to make sure that client connected to the simulator
126+
time.sleep(3)
127+
122128
try:
123129
while(True):
124-
#Counting the loops
125-
130+
# Counting the loops
126131
counter = counter + 1
127132

128-
#Set the power of the engine of the car to 20, Negative number for reverse movement, Range [-100,100]
129-
car.setSpeed(50)
133+
# Set the power of the engine the car to 20, Negative number for reverse move, Range [-100,100]
134+
car.setSpeed(20)
130135

131-
#Set the Steering of the car -10 degree from center
136+
# Set the Steering of the car -10 degree from center, results the car to steer to the left
132137
car.setSteering(-10)
138+
139+
# Set the angle between sensor rays to 30 degrees, Use this only if you want to set it from python client
140+
car.setSensorAngle(40)
133141

134-
#Get the data. Need to call it every time getting image and sensor data
142+
# Get the data. Need to call it every time getting image and sensor data
135143
car.getData()
136144

137-
#Start getting image and sensor data after 4 loops. for unclear some reason it's really important
145+
# Start getting image and sensor data after 4 loops
138146
if(counter > 4):
139-
#returns a list with three items which the 1st one is Left sensor data, the 2nd one is the Middle Sensor data, and the 3rd is the Right one.
147+
148+
# Returns a list with three items which the 1st one is Left sensor data\
149+
# the 2nd one is the Middle Sensor data, and the 3rd is the Right one.
140150
sensors = car.getSensors()
141-
#EX) sensors[0] returns an int for left sensor data in cm
142151

143-
#returns an opencv image type array. if you use PIL you need to invert the color channels.
152+
# Returns an opencv image type array. if you use PIL you need to invert the color channels.
144153
image = car.getImage()
145154

146-
#returns an integer which is the real time car speed in KMH
155+
# Returns an integer which is the real time car speed in KMH
147156
carSpeed = car.getSpeed()
148157

149-
#Don't print data for better performance
150158
if(debug_mode):
151-
print("Speed : ",carSpeed)
152-
#currently the angle between the sensors is 30 degree TODO : be able to change that from conf.py
153-
print("Left : " + str(sensors[0]) + " | " + "Middle : " + str(sensors[1]) +" | " + "Right : " + str(sensors[2]))
154-
155-
#Showing the opencv type image
159+
print(f"Speed : {carSpeed}")
160+
print(f'Left : {str(sensors[0])} | Middle : {str(sensors[1])} | Right : {str(sensors[2])}')
161+
162+
# Showing the opencv type image
156163
cv2.imshow('frames', image)
157-
#break the loop when q pressed
164+
165+
158166
if cv2.waitKey(10) == ord('q'):
159167
break
168+
160169
time.sleep(0.001)
161-
#A brief sleep to make sure everything
162-
170+
163171
finally:
164172
car.stop()
165173
```
@@ -189,10 +197,10 @@ Set the thottle and steering of the car by adding
189197
>2. Steering value Range : [-100,100] - "0 is Center"
190198
191199
``` python
192-
#Set the speed of the car
200+
# Set the speed of the car (This will not set the actual speed of the car, thus to achieve a certain speed, checking the speed feedback is required.)
193201
car.setSpeed(50)
194202

195-
#Set the steering of the car
203+
# Set the steering of the car
196204
car.setSteering(0)
197205
```
198206

@@ -211,7 +219,7 @@ image = car.getImage()
211219
carSpeed = car.getSpeed()
212220
```
213221

214-
warning "It's highly recommended to add your Algorithms to the Example.py Code."
222+
Warning "It's highly recommended to add your Algorithms to the example.py Code."
215223

216224
# Calibrate your Camera (Version 1.0.5 or higher).
217225
You can calibrate your camera with a Simulated Checkerboard.
@@ -221,4 +229,4 @@ Camera Calibration Test 1 | Camera Calibration Test 2
221229
![Image of Calibration](http://avisengine.com/wp-content/uploads/2021/01/Screen-Shot-2020-08-11-at-12.35.39-AM.png) | ![Image of Calibration2](http://avisengine.com/wp-content/uploads/2021/01/Screen-Shot-2020-08-11-at-12.35.52-AM.png)
222230

223231

224-
last update : January 20, 2022
232+
last update : April 3, 2023

0 commit comments

Comments
 (0)