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.
This example computed time from length, to then drive for that time. Since there is now simply a function to drive straight for a given distance, use that instead.
Also add wait after drive(0, 0) to give it some time to reach that speed (a standstill).
Also fix ImageFile import
Breaking changes were made in the motor API.
The stop(Stop.*) methods was split into explicit methods and the stop
argument in run_* methods was renamed and the default value changed in
some cases.
This is a demo of:
- multi-file project
- using images
- creating a "menu"
This program can be started away from the competition table.
Then a mission can be quickly activated by pressing one of the buttons.
Functionality is still not quite the same as EV3-G/Scratch.
action_update() should remember the old speed during ultrasonic
reaction and then restore it.
Also, tuning is a bit off since loop time is ~26ms compared to ~18
in EV3-G/Scratch.