alireza787b / mavsdk_drone_show

All in one Drone Show and Smart Swarm Solutin for PX4
86 stars 22 forks source link

Connecting to Pixhawk Hardware #8

Closed turkanispak closed 8 months ago

turkanispak commented 10 months ago

Hello, I have followed your instructions on the YouTube tutorial and got the system working in sitl. I am a beginner and want to try out the offload_from_csv.py using square shape. I cannot figure out which lines I have to edit to connect to an actual pixhawk hardware. I tried the following, Edited line 76 with system() to connect to serial acm0 Edited line 197 with mavsdk server But both of them did not give results, any help is greatly appreciated.

alireza787b commented 10 months ago

Hello,

Firstly, thank you for your interest in the project and for trying it out. keep me posted with the real flight reports please...

To connect to an actual Pixhawk hardware, you need to set the connection string to the serial port that the Pixhawk is connected to. This is usually something like /dev/ttyACM0 for Linux or COM3 for Windows.

In the newer versions of the project, you can set this in the params.py file. Look for the serial_mavlink_port variable and set it to your Pixhawk's serial port. Also, make sure to set the serial_mavlink variable to True.

If you're using an older version of the project, you might need to set this manually in the offboard_from_csv.py. script. Look for the System object initialization and change the system_address parameter to your Pixhawk's serial port.

Before you try to run the project with a real Pixhawk, I recommend running one of the MAVSDK Python examples to make sure that the connection to the Pixhawk is working correctly. You can find these examples in the MAVSDK-Python examples directory.

Also, I have added an offboard_from_csv.py example in the latest MAVSDK-Python official examples. You might find it easier to follow the logic in this example.

Please note that flying in the real world can be very different from the simulation. Make sure you understand all the safety considerations and be prepared for any scenario. Always test in a safe and controlled environment.

Best regards,

turkanispak commented 9 months ago

Hello,

Thank you for the quick response. I have tried the official mavsdk examples. I have got them to work eventually (it seems that qgc was automatically connecting to Pixhawk so I used a different computer and telemetry to connect to qgc). Afterwards I returned to offboard_from_csv.py script located in the main directory of the project folder. I have changed the connect line as await drone.connect(system_address="serial:///dev/tty/ACM0:115200 but the code is stuck at waiting to discover system on udp://:14540. Terminal output is as follows,

[07:31:54|Info ] MAVSDK version: v1.4.0-483-gea0b7205-dirty (mavsdk_impl.cpp:23) [07:31:54|Info ] Waiting to discover system on udp://:14540... (connection_initiator.h:20)

Any ideas are appreciated.

alireza787b commented 9 months ago

ah, one point. which version you are using? from a version, I didn't update the offboard from CSV anymore. might have some deprecated function. instead I uploaded corrected documented offboard from CSV to official mavsdk example folder. check that in the offical example fodelr of mavsdk python it also has a good documentation for that https://github.com/mavlink/MAVSDK-Python/tree/main/examples/offboard_from_csv