Elecom Wireress GamePad (1)

DonkeyCar3の構築

FaBoのDOcsを参考して RaspPi3のインストール  をした。

いよいよ走行テストです。

結果的にWeb操縦はOKだが、ELECOM Wireress GamePadからの操作は失敗なので、記録として残す。

Webから操縦

コマンドラインからpython manage.py driveで起動する。

(env) pi@donkeypi3chen02:~/mycar $ python manage.py drive
using donkey v3.1.0 ...
loading config file: /home/pi/mycar/config.py
loading personal config over-rides

config loaded
cfg.CAMERA_TYPE PICAM
cfg.CAMERA_TYPE PICAM
PiCamera loaded.. .warming camera
Adding part PiCamera.
Starting Donkey Server...
Adding part LocalWebController.
Adding part ThrottleFilter.
Adding part PilotCondition.
Adding part RecordTracker.
Adding part ImgPreProcess.
Adding part DriveMode.
Adding part AiLaunch.
Adding part AiRunCondition.
Init ESC
Adding part PWMSteering.
Adding part PWMThrottle.
Tub does NOT exist. Creating new tub...
New tub created at: /home/pi/mycar/data/tub_5_19-11-17
Adding part TubWriter.
You can now go to <your pi ip address>:8887 to drive your car.
Starting vehicle...
8887
/usr/lib/python3/dist-packages/picamera/encoders.py:544: PiCameraResolutionRounded: frame size rounded up from 160x120 to 160x128
  width, height, fwidth, fheight)))
WARNING:tornado.access:404 GET /favicon.ico (192.168.0.137) 21.21ms
recorded 10 records
recorded 20 records
recorded 30 records
recorded 40 records

ブラウザから<your pi ip address>:8887 を開き、Webから操縦できた。

ELECOM Wireress GamePadから操縦

Wireless Joystickを使って操縦する方がスムーズなので、ELECOM Wireress GamePadを繋いで、再度起動

(env) pi@donkeypi3chen02:~/mycar $ python manage.py drive --js
using donkey v3.1.0 ...
loading config file: /home/pi/mycar/config.py
loading personal config over-rides

config loaded
cfg.CAMERA_TYPE PICAM
cfg.CAMERA_TYPE PICAM
PiCamera loaded.. .warming camera
Adding part PiCamera.
Adding part PS3JoystickController.
Adding part ThrottleFilter.
Adding part PilotCondition.
Adding part RecordTracker.
Adding part ImgPreProcess.
Adding part DriveMode.
Adding part AiLaunch.
Adding part AiRunCondition.
Init ESC
Adding part PWMSteering.
Adding part PWMThrottle.
Tub does NOT exist. Creating new tub...
New tub created at: /home/pi/mycar/data/tub_7_19-11-18
Adding part TubWriter.
You can now move your joystick to drive your car.
Joystick Controls:
+------------------+---------------------------+
|     control      |           action          |
+------------------+---------------------------+
|      select      |        toggle_mode        |
|      circle      | show_record_acount_status |
|     triangle     |    erase_last_N_records   |
|      cross       |       emergency_stop      |
|     dpad_up      |   increase_max_throttle   |
|    dpad_down     |   decrease_max_throttle   |
|      start       |  toggle_constant_throttle |
|        R1        |   chaos_monkey_on_right   |
|        L1        |    chaos_monkey_on_left   |
|        R2        |      enable_ai_launch     |
| left_stick_horz  |        set_steering       |
| right_stick_vert |        set_throttle       |
+------------------+---------------------------+
Opening /dev/input/js0...
Starting vehicle...
Device name: Smart JC-U3912T
/usr/lib/python3/dist-packages/picamera/encoders.py:544: PiCameraResolutionRounded: frame size rounded up from 160x120 to 160x128
  width, height, fwidth, fheight)))
E-Stop!!!
constant_throttle: True
recorded 10 records
new mode: local_angle
Shutting down vehicle and its parts...
Stopping PiCamera
Part Profile Summary: (times in ms)
+-----------------------+------+------+------+--------+
|          part         | max  | min  | avg  | median |
+-----------------------+------+------+------+--------+
|        PiCamera       | 0.31 | 0.03 | 0.06 |  0.06  |
| PS3JoystickController | 0.20 | 0.06 | 0.09 |  0.09  |
|     ThrottleFilter    | 0.12 | 0.02 | 0.04 |  0.04  |
|     PilotCondition    | 0.13 | 0.02 | 0.03 |  0.03  |
|     RecordTracker     | 0.16 | 0.03 | 0.03 |  0.03  |
|       DriveMode       | 0.15 | 0.02 | 0.05 |  0.05  |
|        AiLaunch       | 0.13 | 0.02 | 0.04 |  0.04  |
|     AiRunCondition    | 0.12 | 0.01 | 0.03 |  0.03  |
|      PWMSteering      | 3.49 | 1.52 | 1.88 |  1.82  |
|      PWMThrottle      | 4.45 | 1.40 | 1.75 |  1.68  |
|       TubWriter       | 6.65 | 2.79 | 3.10 |  2.84  |
+-----------------------+------+------+------+--------+
Traceback (most recent call last):
  File "manage.py", line 572, in <module>
    meta=args['--meta'])
  File "manage.py", line 561, in drive
    max_loop_count=cfg.MAX_LOOPS)
  File "/home/pi/donkeycar/donkeycar/vehicle.py", line 144, in start
    self.update_parts()
  File "/home/pi/donkeycar/donkeycar/vehicle.py", line 194, in update_parts
    outputs = p.run(*inputs)
  File "/home/pi/donkeycar/donkeycar/parts/actuator.py", line 185, in run
    self.left_pulse, self.right_pulse)
  File "/home/pi/donkeycar/donkeycar/utils.py", line 245, in map_range
    y = ((x-X_min) / XY_ratio + Y_min) // 1
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

Device name: Smart JC-U3912Tとして認識されたが、一部の操縦しかできない。set_throttleできないは一番の問題だ!

できるキー:

  1. キー12だけconstant_throttle: として、True/Falseでき
  2. キー11は、プログラムの終了はできる
  3. 左のスディックは、set_steeringできる

Leave a Reply

Your email address will not be published. Required fields are marked *