Scripts with Pixhawk

Hello, I have a doubt about using scripts to control pixhawk.

I have more knowledge with python than with Lua, but is Lua more practical to use?

I read in the wiki you store the Lua scripts in the sd card of Pixhawk, can you also do it with python/dronekit scripts?

Is it a requirement to use a raspberry pi with python scripts?

1 Like

You need an on board controller if you want to run your python code in the vehicle.
Flight controller only supports Lua for scripting.
Lua is also practical to use if your processing power requirements is as low as the flight controller can maintain. F7 processor boards have more processing power than F4 series boards.
Raspberry pi is not a requirement as a on board computer but it’s well maintained by the so many contributors and its quite popular. Also it’s really cheap. If you give some detail to us what you want to achieve in your project we can help you better.

Well, I am using a pixhawk and the drone is to be used as a crop sprayer,while also being able to dodge obstacles, precision accuracy, maybe image processing, and functions like, if the pesticide is low on volume ,return to base, while saving the last position

Obstacle avoidance is already available in arducopter. Location accuracy depends on GPS module that you are using. Some modules can give sub meter accuracy. Image processing is huge area. Even some applications can not be done using raspberry pi level single board computers. Pesticide level can be measured using raspberry pi and some liquid level indicator module. Rtl already supported as a flight mode but for saving the last position you can maintain the power on the flight controller while changing the main batteries. This means that you need more than one batteries. Or you can write some scripts on the companion computer to store the information from the last mission.

In your opinion, if you can give examples, what are the cases where you need/ or becomes more practical/efficient to use python scripts than only using ardupilot/mission planner?

1 Like

BTW the flight controller can directly control the sprayer. As soon as you want to do image processing or LTE communication, you need a companion computer. For all else the flight controller should be enough

Hello @amilcarlucas, thank for the answer. Yes I can control the sprayer, but can I still use flight controller if I wanted to use the value of a sensor as a condition for the sprayer?

To increase the level of autonomy, robustness, efficiency, situational awareness, decrease human error, etc… You can do most of the capabilities of the ardupilot using a ground control software like mission planner and qgroundcontrol, but this solution is semi autonomous kind of solution to solve a real world problem. With trusted vehicles and well written codes, after takeoff, they just solve it for you.

You can use the fuel level battery backend to trigger RTL based on sprayer tank level.
https://ardupilot.org/copter/docs/common-fuel-sensors.html