Automatic Obstacle Avoidance - ADEEPT AWR Wheeled Robot Manual

4wd smart robot kit compatible with raspberry pi 4 3 model b+ b, opencv target tracking
Table of Contents

Advertisement

85

16 Automatic Obstacle Avoidance

●The ultrasonic module of this product can only move up and down with the camera, and the left and right
movement can only rotate with the body of the body, and can not move left and right relative to the body, so the
obstacle avoidance function of this robot is relatively simple, as long as there is an obstacle in front Turn left
and retreat if the obstacle is too close, and move forward if the obstacle is far away or there is no obstacle.
●The automatic obstacle avoidance function is based on the ultrasonic ranging module, so before writing
your project, you must first put ultra.py RPIservo.py and copy move.py to the same file directory as your
project, and then use the following code to use the automatic obstacle avoidance function.
import
ultra
import
move
import
time
import
Adafruit_PCA9685
import
RPIservo
# Get the initial data of pwm
def
num_import_int(initial):
global
r
with
open(thisPath+"/RPIservo.py")
for
line
in
f.readlines():
if(line.find(initial) == 0):
r=line
begin=len(list(initial))
snum=r[begin:]
n=int(snum)
return
n
scGear = RPIservo.ServoCtrl()
scanNum =
3
represents left, 2 represents middle, and 3 represents right
scanPos =
1
middle and right
scanDir =
1
scanList = []
# Record the distance of obstacles in three directions that are scanned
scanServo =
1
scanRange =
100
rangeKeep =
0.7
as
f:
# servo control
# The car will scan the three parts in front of it, namely left, middle and right, that is, 1
# The next position to be scanned by the car, the value can be 1, 2, and 3 corresponding to left,
# The direction of the car scanning, 1 is the leftmost, -1 is the rightmost
# Pan-tit servo number
# The range of the angle scanned by servo
# Threshold, if it is less than it, turns; if it is greater than it, go back

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?

This manual is also suitable for:

Picar-b

Table of Contents

Save PDF