multunus / autonomous-rc-car

Autonomous RC car using Raspberry Pi and ANN
MIT License
306 stars 102 forks source link

Some Questions in Autonomous.py file #9

Closed isrugeek closed 7 years ago

isrugeek commented 7 years ago

Hi @vaidy @manishrc i am little confused because i see some lines of codes cycle_count... what is the purpose adding this lines in each directions operations!

kindly šŸ‘ while True: stream = io.BytesIO() camera.capture(stream, format='jpeg', use_video_port=True) direction = predictor.predict(stream) image_helper.save_image_with_direction(stream, direction) stream.flush() if direction == 'forward': should_brake = True left_cycle_count = right_cycle_count = 0 forward_cycle_count = reduce_speed(pwm, forward_cycle_count) motor_driver_helper.set_front_motor_to_idle() motor_driver_helper.set_forward_mode() elif direction == 'left': should_brake = True forward_cycle_count = right_cycle_count = 0 left_cycle_count = increase_speed_on_turn(pwm, left_cycle_count) motor_driver_helper.set_left_mode() motor_driver_helper.set_forward_mode() elif direction == 'right': should_brake = True forward_cycle_count = left_cycle_count = 0 right_cycle_count = increase_speed_on_turn(pwm, right_cycle_count) motor_driver_helper.set_right_mode() motor_driver_helper.set_forward_mode() elif direction == 'reverse': should_brake = True motor_driver_helper.set_front_motor_to_idle() motor_driver_helper.set_reverse_mode() else: if should_brake: print("braking...") motor_driver_helper.set_reverse_mode() time.sleep(0.2) should_brake = False motor_driver_helper.set_idle_mode() forward_cycle_count = left_cycle_count = right_cycle_count = 0 motor_driver_helper.change_pwm_duty_cycle(pwm, 100) print(direction)

Vignesh1115 commented 7 years ago

Hi @isrugeek, We are reducing the speed of the car while moving forward so that we do not miss sharp turns and we increase the speed on turns so that it can maintain the power to drive the car. If you have a powerful motor driving your car, you can avoid this.

It would be great if we can move conversations around questions you might have to Gitter instead of this repository. I will be closing this issue.