These two are likely the first in a range of generic LEGO trains with a
City Hub and a DC Train Motor. Instead of adding examples to each,
we add generic train examples in a shared folder and link to them.
We reserve these folders specifically for these sets and their B models.
This restores the previously deleted custom StreamRequestHandler.
In the prevous commits, more and more pieces from the standard socket library were used instead of the custom-made ones made for EV3. This was giving compatibility issues on some platforms (Windows/Mac), and differences with EV3 made it harder to debug.
It was previously dropped to make the MailboxHandler work. This commit reverts that change and modifies the MailboxHandler instead to make it work with the BluetoothSocket objects, which do not have rfile.read. Instead we use recv directly and rely on zero length to detect disconnected state.
It would be useful to eventually use only components from the socket server module and no incomplete custom ones, but this provides at least a working cross platform starting point to fall back to.
Technically it does not matter much who is the server or the client.
However, if Windows PCs are involved, we found it to be easier if
Windows is the client and EV3 is the server.
That way, it is the Windows PC initiating the connection. It doesn't
seem to like it when other devices take the initiative.
So, we update the example accordingly to make it
accessible for most users without loss of generality.
You can still make the PC the server by just running the
server example on your PC.
Even though our main example will have the PC as the server, make it possible to use it as client as well.
Now, it works just like the EV3s. The only difference is that
you must enter the full address instead of the name if the EV3 is the server you are connecting to.
This removes the MicroPython struct and socket specifics and replaces them with Python3 counterparts.
Also a few changes are made to deal with strings, which on MicroPython are just bytes.
Now, the server works on Python3 and client EV3s can connect to it.
This is a copy of the EV3 server example with minimal changes
to make it run on a PC, using the unmodified MicroPython Unix port.
This is done by skipping the name resolver. The downside is that you
must specify the EV3 server address instead of its name. However,
since in this example the PC will be the server, this is not really a
problem. The EV3 clients will just connect to the PC by its name.
This copies the Pybricks MicroPython bluetooth implementation. As-is, it only runs in Pybricks MicroPython.
The next commits will adapt it to work with MicroPython and then Python3. We only need the Python3 end result, but this staged approach makes it easy to keep track of what will be changed.
Add a header with links to the LEGO Education website for building
instructions and SD card image download. This way if someone gets a
copy of the program, they don't have to go searching for documentation.
30% is near the static friction limit of the medium motor itself. In the latest tests, the motor was stalling without moving, so bump up the minimum duty cycle to fix it with a reasonable safety margin.
Remove extra gyro_offset factor that causes gyro_bot to not leave the stand.
My gyro sensor has an offset of -17 which causes gyro_offset to become very large with this calculation.
Since the code is using the `*=` operator, the current calculation is `(1 - GYRO_OFFSET_FACTOR) * gyro_offset * gyro_offset`, but I believe the desired calculation is `(1 - GYRO_OFFSET_FACTOR) * gyro_offset` to make this moving average correct.