Errors in misc_examples.py

If you try to run this it says:

MicroPython v1.20.0 on 2023-04-26; Raspberry Pi Pico W with RP2040
Type "help()" for more information.
>>> 
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "XRPExamples/misc_examples.py", line 2, in <module>
ImportError: can't perform relative import
>

Also, there is no line of code which would actually run anything even if the import was fixed. Perhaps it needs:
ivp()

It does look like there is an error in our handeling of this program. If you change line 2 from
from .drive_examples import test_drive
to
from XRPExamples.drive_examples import test_drive

You are also correct that this program will not do anything without some calls. They are meant as examples for students to use.

1 Like

I don’t know Python nor am I familiar with this particular development environment. I suspect many students will be in the same boat. Therefore it would be nice to have an example of how to use these pieces of sample code. I didn’t see anything in the course curriculum which showed that.

It is pretty basic to call the functions but I do agree that something like this would be helpful:

# Uncomment (remove the  #) the line below for which function you want to run
# test_leds()
# test_servo()
# ivp()

Seems to me that section 2.5 of the canvas curriculum (which needs to be completely rewritten since it’s for the old beta version of the XRP) would be a good place to explain how to run all the example software.

Or perhaps in the XRPUsersGuide?

This document overlaps in content with the Canvas course which is rather confusing.

It seems that most of the other code snippets assume you already know how to structure and run python code.