2016年4月11日 星期一

build apm source code on raspberry


記得要用RPI2 歐 ....RPI3 不能執行


Building APM

These steps are the same both for compiling APM directly on Raspberry Pi and cross-compiling.
Download the APM’s port for Navio:
git clone https://github.com/emlid/ardupilot.git




安裝   gawk

sudo apt-get install gawk


cd ardupilot/APMrover2
make navio

cd ardupilot/ArduPlane
make navio

cd ardupilot/ArduCopter
make navio

If you are compiling directly on Raspberry copy the binary from tmp directory to your home folder:
cp /tmp/APMrover2.build/APMrover2.elf /home/pi/APMrover2.elf
Instructions how to run APM on Raspberry and to connect GCS to it are available here.

Running APM

To run APM use the following (change APMrover2.elf to ArduCopter.elf or ArduPlane.elf if needed):
sudo ./APMrover2.elf -A udp:192.168.1.2:14550
Where 192.168.1.2 is the IP address of the device with the Ground Control Station – your laptop, smartphone etc.

Arguments specify serial ports (TCP or UDP can be used instead of serial ports) :
  • -A is for telemetry
  • -B is for external GPS
  • -C is for secondary telemetry




編譯 navio 2.0

Building APM using make-based build system

These steps are the same both for compiling APM directly on Raspberry Pi and cross-compiling.
Download the APM code and update submodules:
git clone https://github.com/diydrones/ardupilot.git
cd ardupilot
git submodule update --init
Navigate to the autopilot’s directory: APMrover, ArduCopter or ArduPlane. For example ArduCopter:
cd ArduCopter
Build for quadcopter:
make navio2-quad

================================================================
sudo ./ArduCopter.elf

結果如下:

0 0 0 ▒ Q}▒MPU9250: unexpected WHOAMI 0x0
AK8963: MPU9250 not configured for AK8963
No Compass backends available
COMPASS INIT ERROR

看起來沒有 MPU9250 和   Compass ...

查了一下  libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp

  uint8_t whoami = _register_read(spi, MPUREG_WHOAMI);
    if (whoami != MPUREG_WHOAMI_MPU9250 && whoami != MPUREG_WHOAMI_MPU9255) {
        hal.console->printf("MPU9250: unexpected WHOAMI 0x%x\n", (unsigned)whoami);
        goto fail_whoami;
    }

目前板子是沒有插上 MPU9250


MPU9250 的 pin function

spi 用到   AD0 (SDO),  nCS (CS),  SCL(SCLK),  SDA(SDI)


Note: To prevent switching into I2 C mode when using SPI, the I2 C interface should be disabled by setting the I2C_IF_DIS configuration bit. Setting this bit should be performed immediately after waiting for the time specified by the “Start-Up Time for Register Read/Write” in Section 6.3. For further information regarding the I2C_IF_DIS bit, please refer to the MPU-9250 Register Map and Register Descriptions document.



Reference : http://www.emlid.com/navio-apm/
Reference  : http://www.emlid.com/navio-building-apm/

沒有留言:

張貼留言