Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulator #351

Closed
wants to merge 67 commits into from
Closed

Simulator #351

wants to merge 67 commits into from

Conversation

kruegercharles
Copy link
Contributor

@kruegercharles kruegercharles commented Nov 15, 2023

How to use

  1. Activate Simulator in Internal Settings
  2. Pick a route and send a Pair Request
  3. The Pairing has to be confirmed from the simulator. For testing purposes the confirmation can be send via the terminal as well (see below under "Publish")
  4. Start ride. The MQTT messages during the ride can be read via the terminal, if subscribed (see below under "Subscribe").

For the detailed protocol see below.

Use MQTT within terminal

The MQTT-Messages can be send & received via the terminal, if mosquitto is installed.
On MacOS: brew install mosquitto

Publish

Replace deviceID with the deviceID shown in the internal settings. The ID resets whenever the app restarts.

mosquitto_pub -h priobike.vkw.tu-dresden.de -p 20036 -t "simulation" -m "{\"type\":\"PairStart\", \"deviceID\":\"ee1e9\"}" -P JsAF0keyKjrJT9LwiUKV0YRdemhUFxhF -u app

Subscribe

No need to use a deviceID.

mosquitto_sub -h priobike.vkw.tu-dresden.de -p 20036 -i "client-id" -v -t "simulation" -P Qe6irlBho9JJXbWHQQ1PB6qxHjtAHEJ9 -u simulator

Communication protocol

Step 1: If the user activated the simulator and then tries to start a ride, a pair request is sent to the simulator.
{"type":"PairRequest","deviceID":"90610","deviceName":"Priobike"}

Step 2: The server has to confirm the pairing.
{"type":"PairStart", "deviceID":"90610"}

Step 3: The app sends the first point of the route to position the simulator at the start of the route.
{"type":"FirstCoordinate","deviceID":"90610","longitude":"9.993682","latitude":"53.551086","bearing":"0.0"}

Step 4: The user has to start to ride.
Step 4.1: The app sends all the points of the route.
[{"type":"RouteDataStart","deviceID":"90610"},{"lon":9.993682,"lat":53.551086},...,{"lon":9.976977980510583,"lat":53.56440493672994}]

Step 4.2: The app sends all the traffic lights on the route.
{"type":"TrafficLight","deviceID":"90610","tlID":"hamburg/333_42","longitude":"9.9861116","latitude":"53.5476128","bearing":"109.60459330886522"}

During the ride:
The app sends an update of the current position once a second.
{"type":"NextCoordinate","deviceID":"90610","longitude":"9.993686","latitude":"53.551085","bearing":"29.79114808786065"}

The app sends updates for the state of the traffic lights whenever an update is detected.
{"type":"TrafficLightChange","deviceID":"90610","tlID":"hamburg/333_42","state":"green"}

The ride ends whenever the simulator or the app sends a StopRide.
{"type":"StopRide","deviceID":"90610"}

lib/simulator/services/simulator.dart Outdated Show resolved Hide resolved
lib/simulator/services/simulator.dart Outdated Show resolved Hide resolved
web/index.html Outdated Show resolved Hide resolved
@kruegercharles kruegercharles force-pushed the feature/stimulator branch 2 times, most recently from 785f8b2 to 390d79e Compare November 28, 2023 11:46
@kruegercharles kruegercharles force-pushed the feature/stimulator branch 2 times, most recently from b945fa7 to 412339a Compare December 11, 2023 16:06
@kruegercharles kruegercharles force-pushed the feature/stimulator branch 2 times, most recently from 60f80de to 1c658b5 Compare January 6, 2024 10:32
@kruegercharles kruegercharles force-pushed the feature/stimulator branch 2 times, most recently from bdfe834 to fe39043 Compare January 18, 2024 12:42
@kruegercharles kruegercharles marked this pull request as ready for review January 20, 2024 10:25
Copy link
Member

@PaulPickhardt PaulPickhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the code. Still need to test it with the simulator.

@kruegercharles pls check my comments and decide, if changes are necessary or provide a very brief explanation to my questions.

Also check Buttonoverflows after applying my suggestions.

lib/simulator/services/simulator.dart Outdated Show resolved Hide resolved
lib/ride/services/ride.dart Show resolved Hide resolved
lib/ride/views/main.dart Show resolved Hide resolved
lib/ride/views/main.dart Show resolved Hide resolved
lib/ride/views/main.dart Outdated Show resolved Hide resolved
lib/ride/views/main.dart Outdated Show resolved Hide resolved
lib/routing/views/main.dart Outdated Show resolved Hide resolved
lib/routing/views/main.dart Outdated Show resolved Hide resolved
lib/simulator/services/simulator.dart Outdated Show resolved Hide resolved
@kruegercharles
Copy link
Contributor Author

Reviewed the code. Still need to test it with the simulator.

@kruegercharles pls check my comments and decide, if changes are necessary or provide a very brief explanation to my questions.

Also check Buttonoverflows after applying my suggestions.

How can I fix Button-Overflows? It seems to me like this is a problem of the design of the app. I could change the Button to IconTextButton but I'm not sure if this would be in line with the design. Also, I cannot think of a way to shorten the text 😅

@PaulPickhardt PaulPickhardt deleted the feature/stimulator branch February 14, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants