Closed manglemix closed 2 years ago
I have decided to take on this issue because the way I want it to be done may be quite foreign to most of you guys
I should note that MovementIntent messages are also implemented here, alongside the required pings
What must be done To facilitate wireless communication, the robot must have a TCP and UDP client that connects to Lunabase (the name of whatever computer is running the Lunabase GUI that I created). It is better for the robot to connect to Lunabase instead of the other way as the robot can connect when it is ready, and it is expected that Lunabase will have a constant IP address, whereas the robot may or may not get a different IP address as it turns off and on again (unlikely, but why risk it). It is also less fiddling with firewalls on Lunabase, as firewalls tend to block inbound traffic and not outbound.
These clients will likely be in two separate nodes, as they both handle different kinds of traffic. For now, UDP will not be used for the current milestone, so this node is not strictly necessary. However, it will be created very similarly to TCP, so it would be trivial to make it as well.
The way communication shall work is Lunabase will send packets where the first byte always represents the type of message. All other data in the packet represents the body. We only want two messages for now:
SOFT_PING=0
andHARD_PING=1
. The value of a header is very important, and must be the same between lunabot and lunabase, so future changes must preserve this.A
SOFT_PING
represents a software ping, which just means that lunabot should return the exact same packet back to lunabase. The body will not be read, and it is fine if there is or isn't one.A
HARD_PING
represents a hardware ping, which does both aSOFT_PING
and some sort of visible physical activity. For now, we should just leave a comment where this code should go, but in the future it will be replaced with a message that triggers the movement of a motor.Existing 3rd party solutions It is unlikely that we will find a library outside of Python's
socket
library that will help us accomplish this, and that library is all we really need anyways. However, if you guys find a library with a bit more abstraction that fits our use-cases, do not be afraid to mention them here!Existing internal solutions We have a verbose and monolithic
telemetry
node inusr_ws_2021/src/telemetry/scripts/telemetry.py
. Trying to understand it may help, but I encourage you guys to just try it yourself.Quirks or Specifics TCP and UDP are both fundamentally different technologies. Understanding them is paramount to our goals as a club and your life as a software developer in general. Spend some time messing around with the differences, and feel free to use the Github Team discussion if you are confused.
This is a big task, so do not feel afraid to create sub-tasks for this