Pixhawk PX4 in study and research! Where to start?

i’m a college student and i’m using PX4 for my project in my university.
In this project, i want to control my drone to go left, go right 10m,… or go to any position (without GPS and RC). So where should i start? is it offboard mode?
And i have another question. It seems that pymavlink and mavsdk are used commonly. i think that pymavlink is easier to use because its structure like Messages (common) · MAVLink Developer Guide (eg: pymavlink takeoff: the_connection.mav.command_long_send(the_connection.target_system, the_connection.target_component, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, 0, 0, 0, 0, 0, 0, 0, 10)). But if i use MAVSDK-Python, it is drone.action.takeoff(). Now, for example, if i want the drone to do the command SET_POSITION_TARGET_LOCAL_NED, i dont know how to code with MAVSDK-Python. So what library should i use for learning?
Thank you so much!

Hi there,

If you want to use position control, the drone needs to have some sort of position “sensor”, e.g. VIO, a flow board, GPS, or a motion capture system like VICON/Optitrack.
Without that, you can’t do position control but you can only do time based inputs, e.g. roll 25 degrees for 2 seconds but that will not give you good results as it will drift, and also drift with the wind.

Now regarding pymavlink and MAVSDK, I’m biased as the author/maintainer of MAVSDK, and therefore recommending MAVSDK. The main reason is that MAVSDK has been developed mainly against PX4, so things like offboard control should generally work ok…

I suggest to have a look at the MAVSDK-Python reference docs and the examples, there are some offboard ones right there.

@JulianOes thanks for your response. I’ve tried to run the mavsdk offboard example but QGroundControl said that no offboard signal and didn’t allow to change mode, COMMAND_DENINED. And then, auto disarm. Could you help me to solve this solution? Thank you

Have you tried offboard->start() in code. Do you have some sort of position estimate, e.g. with GPS? Otherwise it likely won’t work.

this is the example code i downloaded from MAVSDK-Python github @JulianOes

Ok, it complains that the landed state is not known, so it fails to start.

I’ll have to try to reproduce this.

I just tried running the example against SITL Gazebo with QGC open, and it worked fine, although it flew very close to the ground, so that would require some tweaking. Of course attitude offboard doesn’t control altitude but only thrust so it’s expected that this would have to be tweaked, or controlled otherwise.

Please note the exact steps you do and I’d try to reproduce your case.

First, i open jmavsim by make px4_sitl_default jmavsim
Then, i open QGC and takeoff the drone
Finally, i run the offboard_altitude.py
Did i miss any step? Thanks

Chào hoàng !! Mình cũng là sinh viên đang nghiên cứu về PX4, Hoàng có thể chia sẻ cách chạy được mô phỏng jmavsim được không ?! Mình dùng window !!

Contact fb mình nhé Redirecting...

I’m not sure because I tried exactly this and it worked just fine for me.

@ hiep_dao_hoang
Where did you place the offboard_altitude.py code. Was it inside a directory on the sdcard