Not exactly sure what your question is, but here is are the basics.
The Megapi is a microcontroller that does a good job with it’s limited resources to run the motors and sensors attached to it. It is NOT a general purpose computer. Most of the demos and example you see are of a general purpose computer (tablet, phone, pc, mac) sending commands via (bluetooth, wifi, usb, serial port) to a simple “firmware” running on the MegaPI.
The raspberry pi takes the general purpose computer role in this. So, for instance, if you install the standard firmware on the MegaPI, then connect it to the raspberry pi either through a USB cable or the GPIO serial connect (pictured in a post above), you can then send the commands that the standard firmware can understand through that serial connection.
Makeblock is supplying a python class (called MegaPI) that will run on your raspberry pi to send those commands and handle the callbacks (for sensor calls).
There are numerous examples in the makeblock git repository here: https://github.com/Makeblock-official/PythonForMegaPi
But the basics are…(once you have the two devices connected), in python:
from megapi import *
bot = MegaPi()
# if you are using the USB port
# otherwise ttyS0 or ttyAMA0 depending on your configuration
There is a good post on setting up the serial port on your RPi here: MegaPi Firmware / Python Interface