- マイコン: AtomS3 + AtomS3 Lite
- ブラシレスモータ: iPower GM2804 (iFlight) x 2
- モータードライバ: TMC6300 (Analog Devices) x 2
- 磁気回転位置センサ: AS5048B (ams OSRAM) x 2
- 使用ライブラリなど : YOLOv8 + Vision(Apple) + Arduino + SimpleFOC
- 3Dプリンタ: Ender-3 S1 Pro (Creality)
- スマホ : iPhone 15 Pro Max
- 車両: YAMAHA XSR900 60th Anniversary
iTrackingCam「自動追尾カメラをイチから作ってみた」
追尾ロジックもモーター制御まで自前でやれたらとイチから作ってみました
iPhoneのカメラで物体を認識し2軸のモーターを駆動
ワンコやバイクに乗ったライダーも遅延なく自動追尾!
DockKitもどき
-
3位M5Stack Japan Creativity Contest 2024
- 動画
-
- 開発素材
- システム構成
-
- ストーリー
-
2度目の投稿です。 前回はオリジナルの車載センサーでバイクの姿勢取得でしたが、今回は「モーターで動く」をお題に「自動追尾カメラ」をイチから作ってみました。
This is my second post. Last time, I used an original on-board sensor to acquire the attitude of a motorcycle, etc. This time, I made an "automatic tracking camera" from scratch with the theme of something that works with a motor.
iPhoneのカメラで物体を認識し2軸のモーターを駆動させます。
The system recognizes one objects with the iPhone camera and drives a 2-axis motor to track it.
走る犬やバイクに乗ったライダーも自動追尾できます(機械学習でなんでも追えるはず)
It can automatically track a running dog or a rider on a motorcycle! (Machine learning should be able to track anything)
最初は、iPhoneとマイコン間のUDPのパケ詰まりなどで応答性がよくなかったのですが、通信遅延を自動調整するロジックを組むことで、ラグなく追尾できるようになりました。
At first, responsiveness was not good due to jammed UDP packets between the iPhone and the microcontroller, but by building in logic to automatically adjust the communication delay, we were able to track the device without lag.
ハードウェアは、音が静かで応答性に優れ、中空軸という利点からブラシレスモーター(以下、BLDC)を使うことにしました。
In the hardware design, I chose to use brushless motors ("BLDCs") because of their quietness, responsiveness, and hollow shaft.
BLDCの駆動は、6つのPWMで微細に制御、回転角センサーはI2Cと、8本の信号線が必要になりますが、M5Stack社のAtomS3の端子数がぴったりだったので、これをコアにFusion360で筐体をモデリングしてみました。
The BLDC drive is finely controlled by six PWMs, and the rotation angle sensor is I2C, requiring eight signal lines. The number of terminals on M5Stack's AtomS3 was perfect, so I modeled the enclosure in Fusion360 with this as the core.
2軸なので、モーター毎にマイコンひとつという贅沢設計です(汗
Since it has two axes, it is a luxury design with one microcontroller for each motor.
- 通信遅延を自動調整するロジック/Logic for Automatically Adjusting Communication Latency
スマホ(カメラ兼AI認識)は画面中心からの距離を(スマホ座標系のローカル)回転角として、AtomS3にUDPで送信しています。
The smartphone (camera and AI recognition) transmits the distance from the center of the screen as a rotation angle (in the smartphone's local coordinate system) to the AtomS3 via UDP.
スマホから回転角をM5に連続で送信することで追従は出来そうですが...
Although continuous transmission of the rotation angle from the smartphone to the M5 could enable tracking...
UDP通信のM5への到達時刻は一様ではないため、追従の遅れや意図しない回転などの誤動作になります。
the arrival times of UDP packets at the M5 are not uniform. This results in tracking delays and unintended rotations, causing malfunctions.
解決策として考案したロジックは、タイムスタンプとグローバル回転角のタイムテーブルです。
The solution I devised involves a logic based on timestamps and a global rotation angle timetable.
- スマホは、スマホローカル回転角と共にタイムスタンプを付与して送信
The smartphone sends the local rotation angle along with a timestamp.
- AtomS3側はmsec単位の過去1秒間分のグローバル回転角と時刻のテーブルの常時更新保持
The AtomS3 maintains and constantly updates a table of global rotation angles and their corresponding timestamps for the past second in millisecond units.
- AtomS3は、スマホローカル回転角を受信したら、タイムスタンプを元に過去のグローバル回転角情報を取得
Upon receiving the smartphone's local rotation angle, the AtomS3 retrieves the past global rotation angle information based on the timestamp.
- そのグローバル回転角にスマホローカル回転角を加算してモーターを回します。
The AtomS3 then adds the smartphone's local rotation angle to the corresponding global rotation angle and rotates the motor accordingly.
- 類似の技術 / Similar Technology
実は、作り始めてから知ったのですが... Appleから「DockKit」という同様なエコシステムが発表され、BelkinやInsta360からも対応ハードウェアも出ました。
Actually, I only found out about it after I started building... Apple announced a similar ecosystem called "Dockkit" and compatible hardware from Belkin.
自分でイチから作ると理解できること沢山ありますし、楽しかったのでヨシ!Appleと同時期に同じようなものを作ってたなんて光栄だと思っています。
It was a lot of fun, and I was honored to be making something similar to Apple's at the same time.
- 今後の課題 / Future issues
- バッテリーが少し大き過ぎたので小型化 / Battery is too large.
- 3軸にしてジンバル化 / Make it 3-axis and implement gimbal function.
- 複数人対応。同一人物の永続追尾など / Support for multiple people. Ability to track the same person continuously.
- メンバー
-
-
- Takumi Abe @takumi
-
- ぜんぶやる
-
- 関連イベント
-
-
M5Stack Japan Creativity Contest 20242024-06-01 開催
-
- 関連リンク
- 同じニオイがする作品
-
-
opniz
-
多機能!自転車用テールランプ
-
専用アプリでマウス・キーボードの動作を設定登録「HHKM」
-
HoooPizza
-
YouTubeにて紹介させていただきました!
https://youtube.com/live/BKjBP7Rf6-0
67番目はスマホ搭載自動追システム。この作品は効果はすばらしく、必要な技術を上手に使いつつ、こだわりの制作レベルも素晴らしい作品でした。