Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def isStuck(S,stuck_count):
- max_unstuck_angle = 0.5 # radians
- max_unstuck_speed = 5*3.6 # km/h
- min_unstuck_dist = 1 # m
- #print 'angle %s' %S['angle']
- if abs(S['angle']) > max_unstuck_angle and S['speedX'] < max_unstuck_speed and abs(S['trackPos']) > .2:
- print 'in stuck mode'
- if stuck_count > 200 and S['trackPos'] * S['angle'] < 0:
- stuck = True
- else:
- stuck_count+=1
- stuck = False
- else:
- stuck_count = 0
- stuck = False
- return stuck_count, stuck
- # INSERT IN DRIVE MODULE
- if stuck:
- R['steer'] = - S['angle'] * 0.785398 # steerlock number
- R['gear'] = -1
- R['accel'] = 0.5
- R['brake'] = 0
- # MAINTAIN STUCK COUNT SOMEWHERE OUT OF DRIVE MODULE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement