2
$\begingroup$

I have:

  1. Raspberry Pi 3.
  2. Pi camera.
  3. CC3D flight controller.

I have already developed a Python script that decides whether the quadcopter dron has to turn left/right, move straight on or to stop.

Is there a way to connect the Raspberry Pi to the flight controller to send it the commands?

Is it as easy as it sounds?

Edit: I can change the flight controller if necessary.

$\endgroup$
3
$\begingroup$

The easiest way to do this would be using UART for serial communication. The CC3D has TX/RX/GND pins which you connect to Raspberry Pi.

Now you will need some sort of protocol or data framing to send pitch/roll/yaw/throttle values to the flight controller and differentiate these values somehow. You can implement and use the MultiWii Serial Protocol for this purpose. Flight controller firmware such as CleanFlight already support MSP. On the RaspPi, PyMultiWii can be used to handle MSP frames.

What is the format or range of the controls the python script decides for the quadcopter? You will have to convert or map these values into MSP RC frame format. The pitch/roll/yaw/throttle range in MSP is 1000-2000 (centered at 1500 at pitch/roll/yaw) and 1000 for throttle stops all motors and 2000 is the max value for throttle. The RC frame also support 4 AUX channels, where you can send any sort of data you want. Here's a good tutorial for implementing MSP with python and STM32 microntroller (which is used on CC3D).

Tip: You can also make use of the MSP attitude and heading frame to get the pitch, roll and yaw computed from the IMU on the flight controller and integrate this with your Python script on RaspPi for better control!

enter image description here enter image description here

$\endgroup$
  • $\begingroup$ My python script just decides the time in seconds that the drone should execute a movement. For example: turn left until 2.344 seconds and then stop. So the flight controller makes the drone to move to the left for 2.344 seconds, at the same time that it holds the drone well stabilished on the air. $\endgroup$ – Oscar Martinez Jul 22 '17 at 12:33
  • $\begingroup$ If your drone is stabilized already, this is just a matter of setting the pitch/roll rate as inputs to your controller. If you are using some open-source flight controller firmware such as CleanFlight on CC3D, you can use MSP-SET-RC to set your input rates. As I mentioned earlier, you will have to map your timings to the range 1000-2000. $\endgroup$ – Heethesh Jul 24 '17 at 0:46
  • $\begingroup$ Thanks. I have read the tutorial you mentioned, and I understand the code, but I dont know how he is setting up the connection between RaspberryPi and flight controller. Do you know where can I find a better example? $\endgroup$ – Oscar Martinez Jul 24 '17 at 6:42
  • $\begingroup$ In the tutorial, Wi-Fi is used for wireless communication with a PC. There's an on-board ESP8266 wifi module on the flight controller. In your case, you will have to create a wired connection (using TX/RX/GND). Here is an example of UART on RaspPi. And here is a guide on installing CleanFlight firmware on your CC3D board. $\endgroup$ – Heethesh Jul 24 '17 at 8:12
  • $\begingroup$ But CC3D has an INPUT of yaw/pitch/roll/throttle, can I connect raspberry to that input instead of TX/RX/GND ? $\endgroup$ – Oscar Martinez Jul 24 '17 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.