Git Product home page Git Product logo

plarail2021-soft's People

Contributors

acavalkyrie avatar azuki-bar avatar dependabot[bot] avatar gotti avatar ho-0520-it avatar hutinoatari avatar otariidae avatar rhoggs-bot-test-account avatar ruu413 avatar sakuramochi708 avatar

Stargazers

 avatar

Forkers

kokenbot ueckoken

plarail2021-soft's Issues

ping to client

externalからclientに対してpingを送信したい。構造体にmessagetypeみたいなフィールド付けてpingか同期かclientから識別できるようにしませんか

Reactの状態管理

ぱっと思いついた案:

  • Redux
    • Reactにおける状態管理のデファクトスタンダード、決定版
    • Single Source of Truth、純粋な関数による状態遷移を哲学とする
    • opinionated なラッパーであるRedux Toolkitもある
  • Recoil

個人的には新しいもの好きなのでrecoilを使ってみたい

prometheusで監視する項目

external

  • 同接
  • クライアント側エラー数およびエラーメッセージ
  • 単位時間のリクエスト数
  • grpcエラーメッセージ
  • 現在登録されている状態すべて

internal

  • grpcエラーメッセージ
  • 各esp32との疎通状況

列挙したものをメトリクスとして使う。たとえばエラー数のエラー内容などはラベルとして設定して多次元な感じにする

配信映像を表示する

車載カメラの映像がWebRTCで配信されるようなので、それを表示する
ドキュメントはまだないっぽいけど、frontend/videoCast に昔の実装の名残があるらしいので参考にする

速度制御のインターフェース

現実と同じようにワンハンドルマスコンっぽい見た目にすればカッコイイと思ったが、現実のマスコンが加速度(制動・惰行・力行)を操作するのに対してプラレールは速度を直接いじるため、合わないことが判明。
でもプラレールのマスコン製品も合ってない(バック・停止・ゆっくり走行・速く走行)。
割り切ってしまって、マスコンの見た目で速度を操作しちゃってもいい気がしてきた。

change frontend server nextJS -> nginx

next buildが成功したので静的サイトをnginxを使用してホストする形式に変更できないかと考えています。

現状、next startコマンドをDockerコンテナ内で実行することでフロントエンドのサーバを動かしていますが、もし出来るのならばnginxに切り替えたいです。

駅の初期化設定ファイル

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

pythonのwebrtc鯖がちょこちょこクラッシュ

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

速度メーターを表示したい

でも速度は測位点を通過したときのみ算出されるため、リアルタイムの速度を知る方法はないらしい。

この制約のうえでどうにか速度メーターを実現する案:

  • 速度制御APIに送る値をそのまま速度として表示する
    • つまらなそう
    • まるで連続的に速度変化したように見せかけるために投機的に架空の値を表示する?
  • ほかの方法でどうにかリアルタイム速度がわかるAPIを作ってもらう
    • モーターをPWM制御しているプログラムは速度を知ることができるのでは?

internal server fails when receive data from external server

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

read config from config file

サーバのアドレスやポート、TLS証明書のパスなどを外部ファイルにより外挿できるようにしたい。

設定ファイルはコンパイル時に https://pkg.go.dev/embed を使ってバイナリに埋め込むのが良いと考える。

ファイルのフォーマットは何が良いですか?

  • yaml
  • toml
  • (json)

websocket i/o timeout

なんかjs→鯖だけタイムアウトで頻繁に切れるしREST使った単純なのにした方がいいかも

goroutineおかしい

goroutineとクライアントのライフタイム管理をちゃんとやろうね

crash control internal server when accessed

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

地図の描画

地図というか路線図というかリアルタイムマップというか、とにかくあの図の描画方法を検討する

地図に含むべきもの:

  • 線路
  • 車両
  • ストップレール
  • 分岐レール
  • (ホールセンサー)
    • バックエンド側の測位のための部品であり、ユーザーに見せる必要はない?

ぱっと思いついた候補:

  • 画像
    • 状態によって色とか位置とかを変えたくなった時に不便
  • Canvas
    • Reactから扱いにくい
  • SVG
    • よさそう

募集:手書きSVG職人(Reactコンポーネントとして)

ESP32のアドレスと操作対象PINの設定ファイル

見本

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

仕様

name(required)

制御するサーボモータの名前です。 plarail2021-soft/backend/proto/statesync.proto に名前の定義ファイルがあります。
命名規則は <駅名>_<s|n><番号>となっています。 s はストップレール、b は分岐器制御用のサーボモータです。

address(required)

サーボモータを動かす ESP32 のアドレスを指定します。http は省略できません。ポート番号も忘れずに。

pin(required)

ESP32 に制御させるピン番号を指定します。

set_angle, on_angle, off_angle(optional)

もしサーボモータの ON,OFF に特別な角度の設定が必要ならば set_angleを true にしてください。
true に設定した場合 on_angle, off_angleの指定を行う必要があります。

on_angle, off_angle は 0 から 359 までの整数を要求します。

crash when page reload

[]
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

駅の制約条件設定ファイルの記述

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を要求します。

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 をどれか満たしたときに操作を許可します。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.