Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pythonとラズパイで ラジコンカーを自動操縦に!

Pythonとラズパイで ラジコンカーを自動操縦に!

PyCon mini Sapporo 2019 での発表資料です。

MinoruInachi

May 11, 2019
Tweet

More Decks by MinoruInachi

Other Decks in Technology

Transcript

  1. εϩοτϧ18. εςΞϦϯά18. ిݯڙڅ 7 όοςϦిݯ 7 ը૾ .*1* Ϟʔλ੍ޚ໋ྩ *$

    ਪ࿦ 5FOTPS'MPX ,FSBT ˇ  https://www.amazon.co.jp/dp/B07GCKNG72 ˇ  https://www.sengoku.co.jp/mod/sgk_cart/detail.php?code=EEHD-4Z8C ˇ https://www.amazon.co.jp//dp/B01D1D0CX2/ ˇ  https://www.amazon.co.jp/dp/B01LH6SVEC/ ˇ https://www.amazon.co.jp/dp/B00IZ8DRTU/
  2. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp start run run run run run run run
  3. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  4. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  5. Vehicle Memory Timestamp PiCamera {active=true} JoyStickController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp https://github.com/coolerking/donkeypart_game_controller
  6. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  7. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  8. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  9. img_in = Input(shape=(120, 160, 3),
 name='img_in') x = img_in x

    = Convolution2D(filters=24,
 kernel_size=(5, 5),
 strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=32,
 kernel_size=(5, 5),
 strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=64,
 kernel_size=(5, 5),
 strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=64,
 kernel_size=(3, 3),
 strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=64,
 kernel_size=(3, 3),
 strides=(1, 1),
 activation='relu')(x) x = Flatten(name='flattened')(x) x = Dense(units=100, activation='linear')(x) x = Dropout(rate=.1)(x) x = Dense(units=50, activation='linear')(x) x = Dropout(rate=.1)(x) # categorical output of the angle angle_out = Dense(units=1, activation='linear',
 name='angle_out')(x) # continous output of throttle throttle_out = Dense(units=1,
 activation='linear',
 name='throttle_out')(x) 1JMPU/FU
  10. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  11. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle

    timestamp cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  12. Vehicle Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear TwoWheelDifferencialDrive timestamp

    cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle, throrttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp https://github.com/autorope/donkeypart_differential_drive
  13. Memory Timestamp PiCamera {active=true} LocalWebController {active=true} KerasLinear PWMSteering PWMThrottle timestamp

    cam/image_array cam/image_array user/angle, user/throttle
 user/mode, recording Lambda(pilot_condition) user/mode run_pilot cam/image_array pilot/angle, pilot/throttle Lambda(drive_mode) user/mode
 user/angle, user/throttle
 pilot/angle, pilot/throttle angle, throttle angle throttle TubWriter cam/image_array
 user/angle, user/throttle
 user/mode, timestamp
  14. ૸ߦσʔλ ऩू ૸ߦσʔλ ֶश python manage.py train ※ PC or

    Ϋϥ΢υ্ ࣗಈ૸ߦ python manage.py drive —model=ֶशϞσϧ ૸ߦσʔλ ֶशϞσϧ ૸ߦσʔλ௥Ճ Ϟσϧݟ௚͠
  15. img_in = Input(shape=(120, 160, 3), name='img_in') x = img_in x

    = Cropping2D(cropping=((40, 0), (0, 0)))(x) # trim 40 pixels off top x = Convolution2D(filters=24, kernel_size=(5, 5), strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=32, kernel_size=(5, 5), strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=64, kernel_size=(5, 5), strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=64, kernel_size=(3, 3), strides=(2, 2),
 activation='relu')(x) x = Convolution2D(filters=64, kernel_size=(3, 3), strides=(1, 1),
 activation='relu')(x) x = Flatten(name='flattened')(x) x = Dense(units=100, activation='linear')(x) x = Dropout(rate=.1)(x) x = Dense(units=50, activation='linear')(x) x = Dropout(rate=.1)(x) # categorical output of the angle angle_out = Dense(units=1, activation=‘linear', name='angle_out')(x) # continous output of throttle throttle_out = Dense(units=1, activation=‘linear', name='throttle_out')(x)