[Solved] IronPython: missing Script module; or should scripts be run from a specific directory?

Hmm, never used IronPython or MissionPlanner scripts…

From which directory on Windows 10 are IronPython scripts to be run from?

I have installed IronPython on windows 10, and added it to the path.

Running a script I come across states:

clr.AddReference('MAVLink')

However, running this script from a network location and in the IronPython directory leads to unknown reference or similar error.

I had to add

clr.AddReferenceToFileAndPath("C:\Program Files (x86)\Mission Planner/mavlink.dll")

… for the script to find it.

Now I got stuck at NameError: name 'Script' is not defined.

I find this module in other scripts, also without any import statement; e.g.:

Script.ChangeMode("Guided") # changes mode to "Guided"

Hence my initial question:
From which directory on Windows 10 are IronPython scripts to be run from?

Or are there some things I am missing in a new installation of IronPython?


Looking into this further: Script seems to be a class in MissionPlanner?!
https://ardupilot.org/planner/docs/using-python-scripts-in-mission-planner.html

Still a bit a 'Spanish" to me… have tried running a script from the MissionPlanner directory, still no luck.

Mission Planner has an interpreter built in. There’s no need to have a Python (or IronPython) environment specifically installed separately on the machine.

Run scripts from here:
image

Recommend also updating to latest beta Mission Planner from the Help page by clicking the “Check for BETA Updates” button here (also do this somewhat frequently):
image

Beta updates often contain bug fixes and minor updates for recent firmware compatibility. Official releases tend to lag that timeline significantly.

1 Like

As always; thank you kindly…

When I said ‘still no luck’… I encountered this error (and still do), when running the original script (servo_tuner.py) in MissionPlanner:


*** ServoTuner ***

Loading modules...
Loading interface...
Traceback (most recent call last):
  File "\\SynologyNAS\data\46ArgyleCourt\Automation\AutoMower\MissonPlanner\YuriScripts\ArduRover_Mower\servo_tuner.py", line 496, in <module>
  File "\\SynologyNAS\data\46ArgyleCourt\Automation\AutoMower\MissonPlanner\YuriScripts\ArduRover_Mower\servo_tuner.py", line 64, in __init__
TypeError: SubscribeToPacketType() takes at least 4 arguments (2 given)

Line 64 is:

        MAV.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.SERVO_OUTPUT_RAW,
                                  Func[MAVLink.MAVLinkMessage, bool](self.get_servo_data))

Is there a code reference somewhere?


BTW: this is what ChatGPT had to say: AI Answer Question - Ask Any Programming Question, Get Instant Answer

I’m barely qualified to answer MP script questions, even if I wrote it…

They have fallen out of vogue since Lua scripting has largely supplanted the need, and pymavlink works pretty well for custom ground-based Python development.

However, the example I probably used for that particular section is likely this:
MissionPlanner/Scripts/example10.py at master · ArduPilot/MissionPlanner · GitHub

And that doesn’t shed much light.

Full disclosure, I haven’t used the Hall effect tuner in quite some time. It was an afternoon diversion that became a bit entertaining and slightly useful. It could still be quite useful for you, but don’t waste too much time on the Python stuff before just driving around and eyeballing things as best you can with a little help from the data provided by the onboard sensors that you have through the ESP32.

My mower doesn’t even use direct SERVO1 and SERVO3 output anymore. I have a Lua script that resides in-between what amounts to synthetic autopilot throttle commands and actual servo output, manipulating the values based on scaling, offsets, and backlash compensation to get very close to linear output at my desired engine throttle setting. However, that’s VERY experimental and honestly quite painful to configure. It’s not worth the time at this moment to enable (nor do I have time to explain it anytime soon…it really is that bad…).

Instead, don’t agonize too much over straight line tracking. The Hall effect setup will get you close, even if you’re manually manipulating the RC controls to get the required data.

Holy cow… lots to learn…

Yes, I arrived at that sentiment, what I have right now, should suffice to calibrate a straight line.

Again, thank you for you wizard approach to all this… very enlightening.

1 Like