ueckoken / plarail2021-soft Goto Github PK
View Code? Open in Web Editor NEW[Archived] 2021年調布祭プラレール遠隔制御用のコードです。
Home Page: https://chofufes2021.ueckoken.club
[Archived] 2021年調布祭プラレール遠隔制御用のコードです。
Home Page: https://chofufes2021.ueckoken.club
client <-> ?? <-> ?? <-> raspberryPi
となっています。どのような構成を想定していますか?
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/websockets/legacy/server.py", line 232, in handler
await self.close()
File "/usr/local/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 779, in close
await asyncio.shield(self.close_connection_task)
File "/usr/local/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1309, in close_connection
self.transport.write_eof()
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 972, in write_eof
self._sock.shutdown(socket.SHUT_WR)
OSError: [Errno 107] Transport endpoint is not connected
goroutine 50 [running]:
ueckoken/plarail2021-soft-internal/pkg.SendJson({0xc0001320b0, 0x10}, {0xc000334018, 0x16, 0x18}, 0x3b9aca00)
/mnt/live/projects/koken/latest-plarail/plarail2021-soft/backend/internal/pkg/sendJson.go:13 +0x107
ueckoken/plarail2021-soft-internal/internal.(*Send2node).Send2Esp(0xc0000afaa8)
/mnt/live/projects/koken/latest-plarail/plarail2021-soft/backend/internal/internal/sendMsg2Esp.go:34 +0x5e
ueckoken/plarail2021-soft-internal/internal.(*ControlServer).Command2Internal(0xc000116d90, {0x89603b, 0xc0003026f0}, 0xc0003080c0)
/mnt/live/projects/koken/latest-plarail/plarail2021-soft/backend/internal/internal/ServeCommand2Internal.go:24 +0x105
ueckoken/plarail2021-soft-internal/spec._Control_Command2Internal_Handler.func1({0xa78af8, 0xc000302210}, {0x96c660, 0xc0003080c0})
/mnt/live/projects/koken/latest-plarail/plarail2021-soft/backend/internal/spec/statesync_grpc.pb.go:82 +0x78
github.com/grpc-ecosystem/go-grpc-prometheus.(*ServerMetrics).UnaryServerInterceptor.func1({0xa78af8, 0xc000302210}, {0x96c660, 0xc0003080c0}, 0xc000076bb8, 0xc000330228)
/home/gotti/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/server_metrics.go:107 +0x87
ueckoken/plarail2021-soft-internal/spec._Control_Command2Internal_Handler({0x93f0a0, 0xc000116d90}, {0xa78af8, 0xc000302210}, 0xc00032e0c0, 0xc0001aa120)
/mnt/live/projects/koken/latest-plarail/plarail2021-soft/backend/internal/spec/statesync_grpc.pb.go:84 +0x138
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00015a000, {0xa83110, 0xc0000e4480}, 0xc000332000, 0xc00011cd50, 0xe210a0, 0x0)
/home/gotti/go/pkg/mod/google.golang.org/[email protected]/server.go:1279 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc00015a000, {0xa83110, 0xc0000e4480}, 0xc000332000, 0x0)
/home/gotti/go/pkg/mod/google.golang.org/[email protected]/server.go:1608 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
/home/gotti/go/pkg/mod/google.golang.org/[email protected]/server.go:923 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
/home/gotti/go/pkg/mod/google.golang.org/[email protected]/server.go:921 +0x294
exit status 2
昨年使用したPythonで書かれた自動制御コントローラを廃止してExternalと連携して行うサーバを立てる
このPR(#151)の変更によりサーバのサービスポート番号が3000->80になります。
以前変更していただきましたがもとに戻してもらえますか?
Originally posted by @Azuki-bar in #151 (comment)
#141 で作成したモックのイメージを作成する。
メトリクスを取るにあたって最終的にgRPCのエラーコードのみが取得できるのでエラーコードの種類を増やす
表題の通りです。
gRPCはエラーを返すときにエラーコードと共にエラーメッセージを返します。
例:
メトリクス解析時にこのメッセージは取り出せない?
なんとかします
環境変数を上から下まで持っていっていて、最悪になっている
backend/external/pkg/syncController/embed/stationInit.yml にあります。
構文は以下の通りです。
stations:
- name: <駅名_b1>
state: ON
name の引数は駅名_(b|s)数字 となっています。 bは分岐のためのサーボモータでsはストップレール制御用のサーボモータです。
stateは1がON, 2がOFFです。 サーボモータのON, OFFと一致します。
state はON
, OFF
のどちらかの文字列を取ります。(仕様変更@ 20211115)
すべての駅に関して書いて欲しいです。詳細は @Azuki-bar に
サーバのアドレスやポート、TLS証明書のパスなどを外部ファイルにより外挿できるようにしたい。
設定ファイルはコンパイル時に https://pkg.go.dev/embed を使ってバイナリに埋め込むのが良いと考える。
ファイルのフォーマットは何が良いですか?
{"station":{"stationId":1},"state":1}
ぱっと思いついた案:
個人的には新しいもの好きなのでrecoilを使ってみたい
なんかjs→鯖だけタイムアウトで頻繁に切れるしREST使った単純なのにした方がいいかも
stations:
- station:
name: chofu_kudari
points:
- chofu_s1
- chofu_s2
- chofu_b1
- chofu_b2
rules:
- on:
off:
- chofu_s1
- chofu_s2
- chofu_b1
- chofu_b2
- on:
- chofu_s1
- on:
- chofu_s2
- station:
以下に name
, points
, rules
を要求します。
デバッグ用に用いています。 分かりやすい名前を付けてください。
制約条件に記述するサーボモータの名前を列挙します。
on
, off
が含まれるルールを複数指定できます。
ここではon
, off
が最大1つ定義されたものを rule とします。
また rule を複数集めたものを rules とします。
rule のON, OFF はAND条件で効いてきます。記入しない場合は制約条件が無いものと見なします。
上の rules の1つ目の場合、chofu_s1, chofu_s2, chofu_b1, chofu_b2 の全てがOFFであるときに操作を許可します。
複数の rule が定義されている場合、各々の rule をどれか満たしたときに操作を許可します。
でも速度は測位点を通過したときのみ算出されるため、リアルタイムの速度を知る方法はないらしい。
この制約のうえでどうにか速度メーターを実現する案:
[]
2021/10/23 23:44:56 http: response.WriteHeader on hijacked connection from ueckoken/plarail2021-soft-external/internal.unpackClientSendData (clientHandler.go:63)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8255ae]
goroutine 9 [running]:
ueckoken/plarail2021-soft-external/internal.clientHandler.ServeHTTP.func2()
/mnt/live/projects/koken/plarail2021-soft/backend/external/internal/clientHandler.go:42 +0x2e
created by ueckoken/plarail2021-soft-external/internal.clientHandler.ServeHTTP
/mnt/live/projects/koken/plarail2021-soft/backend/external/internal/clientHandler.go:40 +0x265
exit status 2
external
internal
列挙したものをメトリクスとして使う。たとえばエラー数のエラー内容などはラベルとして設定して多次元な感じにする
ref: https://nextjs.org/docs/basic-features/pages
今後の実装方針としてどちらなのか気になったので
もし完全に静的ならStatic HTML Exportが最も楽だと思います
goroutineとクライアントのライフタイム管理をちゃんとやろうね
80%ぐらいの確率で成功して20%ぐらいでコケてほしい
アーキテクチャ考えとらん
next build
が成功したので静的サイトをnginxを使用してホストする形式に変更できないかと考えています。
現状、next start
コマンドをDockerコンテナ内で実行することでフロントエンドのサーバを動かしていますが、もし出来るのならばnginxに切り替えたいです。
externalからclientに対してpingを送信したい。構造体にmessagetypeみたいなフィールド付けてpingか同期かclientから識別できるようにしませんか
地図というか路線図というかリアルタイムマップというか、とにかくあの図の描画方法を検討する
地図に含むべきもの:
ぱっと思いついた候補:
募集:手書きSVG職人(Reactコンポーネントとして)
stations:
- station:
name: chofu_b1
address: http://example.com:80
pin: 1
- station:
name: chofu_b2
address: http://example.com:80
pin: 2
set_angle: true
on_angle: 10
off_angle: 100
制御するサーボモータの名前です。 plarail2021-soft/backend/proto/statesync.proto に名前の定義ファイルがあります。
命名規則は <駅名>_<s|n><番号>
となっています。 s はストップレール、b は分岐器制御用のサーボモータです。
サーボモータを動かす ESP32 のアドレスを指定します。http
は省略できません。ポート番号も忘れずに。
ESP32 に制御させるピン番号を指定します。
もしサーボモータの ON,OFF に特別な角度の設定が必要ならば set_angle
を true にしてください。
true に設定した場合 on_angle
, off_angle
の指定を行う必要があります。
on_angle
, off_angle
は 0 から 359 までの整数を要求します。
Prometheus metrics bind address :9100
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x8936d6]
goroutine 2085 [running]:
ueckoken/plarail2021-soft-internal/pkg/msg2Esp.(*send2nodeExistAngle).Send(0xc00037cc30)
/home/ubuntu/plarail2021-soft/backend/internal/pkg/msg2Esp/send.go:65 +0x36
ueckoken/plarail2021-soft-internal/pkg/serveGrpc.(*ControlServer).Command2Internal(0xc00000f638, {0x8973bb, 0xc00037cb70}, 0xc00035af00)
/home/ubuntu/plarail2021-soft/backend/internal/pkg/serveGrpc/ServeCommand2Internal.go:33 +0x275
ueckoken/plarail2021-soft-internal/spec._Control_Command2Internal_Handler.func1({0xa7ad18, 0xc00037c690}, {0x96e300, 0xc00035af00})
/home/ubuntu/plarail2021-soft/backend/internal/spec/statesync_grpc.pb.go:82 +0x78
github.com/grpc-ecosystem/go-grpc-prometheus.(*ServerMetrics).UnaryServerInterceptor.func1({0xa7ad18, 0xc00037c690}, {0x96e300, 0xc00035af00}, 0xc000055bb8, 0xc00030d4e8)
/home/ubuntu/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/server_metrics.go:107 +0x87
ueckoken/plarail2021-soft-internal/spec._Control_Command2Internal_Handler({0x940a40, 0xc00000f638}, {0xa7ad18, 0xc00037c690}, 0xc0000f0540, 0xc000190660)
/home/ubuntu/plarail2021-soft/backend/internal/spec/statesync_grpc.pb.go:84 +0x138
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000c7dc0, {0xa85450, 0xc000352c00}, 0xc0003306c0, 0xc000196360, 0xe251c0, 0x0)
/home/ubuntu/go/pkg/mod/google.golang.org/[email protected]/server.go:1279 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc0000c7dc0, {0xa85450, 0xc000352c00}, 0xc0003306c0, 0x0)
/home/ubuntu/go/pkg/mod/google.golang.org/[email protected]/server.go:1608 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
/home/ubuntu/go/pkg/mod/google.golang.org/[email protected]/server.go:923 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
/home/ubuntu/go/pkg/mod/google.golang.org/[email protected]/server.go:921 +0x294
exit status 2
現実と同じようにワンハンドルマスコンっぽい見た目にすればカッコイイと思ったが、現実のマスコンが加速度(制動・惰行・力行)を操作するのに対してプラレールは速度を直接いじるため、合わないことが判明。
でもプラレールのマスコン製品も合ってない(バック・停止・ゆっくり走行・速く走行)。
割り切ってしまって、マスコンの見た目で速度を操作しちゃってもいい気がしてきた。
最初が適切な状態とは限らんので初期化処理やりませんか?
Originally posted by @gotti in #137 (comment)
車載カメラの映像がWebRTCで配信されるようなので、それを表示する
ドキュメントはまだないっぽいけど、frontend/videoCast
に昔の実装の名残があるらしいので参考にする
地獄の設定ファイル地獄です
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.