Raspberry Pi 4 using python to send and receive mavlink

I dont know if this is the right place, but I want to set up an obstacle detection system using a lidar, I already have a way on a pi 4 to get most of the data I need from the lidar of any object around the rover. Now the drone itself is a boat and all I want is to know if I can interrupt the pixhawk navigation which is going to be in mission mode so I can move the drone using the obstacle data, and then resume mission mode.

Is this possible using mavlink? can mavlink also send or receive different sets of data since there will be also another program on the pi obtaining GPS data from the pixhawk for other tasks .

The limitation I have is running it in a pi 4 since this is a proof of concept of simple obstacle avoidance I am just curios about the limitations of mavlink. I am also using dronekit , my issue is being able to take over the drone in mission mode, with the script move the drone to a position where the obstacle is not, and then return to mission mode and continue on the waypoints they were before.

2 Likes

Yes you can interrupt the navigation easily with dronekit, you just need to change the mode to GUIDED and then tell it to go x meters north and y meters east with the method goto() on this link, then to continue the mission change the mode back to AUTO.

I don’t know if dronekit is able to share the ttyAMA0 connection with two different programs and even if you could, you would probably have problems with which program edits and reads data first. The easiest thing to do would be to use one program to connect to the pixhawk and do everything there, or even make that program forward the GPS data to the “other tasks” program.

The complete process would be:

  • Load a mission with waypoints to the pixhawk.
  • Let the pixhawk run in AUTO mode.
  • When you detect an obstacle, change to GUIDED mode and calculate how many meters the vehicle must move north and how many east, with that done, use the method goto() and the vehicle will move to that point.
  • Change back to AUTO mode and the vehicle will continue towards the waypoint.
  • Repeat.
1 Like

Yes, thank you. This is the kind of logic that I was working on , in the same thinking. my main concern is during waypoint navigation , if I change from AUTO mode to GUIDED mode, and then go back to AUTO mode, would it still go to the expected waypoint? I am still making sure I can communicate correctly with the pixhawk. and also found out about the simple goto shortly after my question. Once I test it out and confirm it works as expected : changign from AUTO mode to GUIDED Mode and back still mantains current waypoint. I will write over here, thank you!

1 Like