Hexakopter: Difference between revisions

From Rsewiki
No edit summary
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Software configuration for Microkopter
==Hexacopter with MikroKopter flight controller==
How to compile and install software in hexacopter
How to compile and install software in hexacopter
The modifications work best under windows, but some support exist for linux too.
The modifications work best under windows, but some support exist for linux too.
Line 4: Line 8:
This description is for windows (XP)
This description is for windows (XP)


== Get software ==
=== Get software ===


The supplier URL is http://www.mikrokopter.de/ucwiki/en/MikroKopter?action=show&redirect=FrontPage
The supplier URL is http://www.mikrokopter.de/ucwiki/en/MikroKopter?action=show&redirect=FrontPage
Line 14: Line 18:
* kopter-tool to install the software
* kopter-tool to install the software


== SVN checkout ==
=== SVN checkout ===
Install TortoiseSVN from http://sourceforge.net/projects/tortoisesvn/ if you do not have an SVN client already.
Install TortoiseSVN from http://sourceforge.net/projects/tortoisesvn/ if you do not have an SVN client already.


Do a SVN checkout from http://mikrokopter.de/mikrosvn/FlightCtrl/ to get the sourcevode for the flight controler (for other software - e.g. motor controller, the SVN URL is at http://www.mikrokopter.de/ucwiki/MikroKopterRepository)
Do a SVN checkout from http://mikrokopter.de/mikrosvn/FlightCtrl/ to get the sourcevode for the flight controler (for other software - e.g. motor controller, the SVN URL is at http://www.mikrokopter.de/ucwiki/MikroKopterRepository)


== WinAVR ==
=== WinAVR ===


WinAvr version WinAVR-20060421 comes with gcc version 3.4.6 - wich is OK.
WinAvr version WinAVR-20060421 comes with gcc version 3.4.6 - wich is OK.
Line 30: Line 34:
* Compile the project (Tools->make_All) and it should make a *.hex file for one of the Flight-ctrl boards (currently default is version 2.0 with an atMEGA644 processor (Flight-ctrl 2.1 has an atMEGA1284p processor, and one of the first lines in the makefile needs to be changed)
* Compile the project (Tools->make_All) and it should make a *.hex file for one of the Flight-ctrl boards (currently default is version 2.0 with an atMEGA644 processor (Flight-ctrl 2.1 has an atMEGA1284p processor, and one of the first lines in the makefile needs to be changed)


== Install new software ==
=== Install new software ===


To install the newly compiled software use Kopter-tool.
To install the newly compiled software use Kopter-tool.
Line 61: Line 65:


==Pixhawk==
==Pixhawk==
This section is for a configuration, where MikroKopter flight controller is replaced with the more open source pixhawk px4 controller.
This section goes through the software installation (and configuration - once it is in place).
The configurations aren not - as yet - available in any repository, so follow the instructions below to make your own configuration.


===Raw pixhawk installation===
===Raw pixhawk installation===
Line 71: Line 80:
     libftdi-dev libtool zlib1g-dev genromfs git-core wget
     libftdi-dev libtool zlib1g-dev genromfs git-core wget
* On 64bit 14.04: did not install ia32-libs, nor the alternaive: "sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386", as it seems that newer version of the 32bit compiler were there already.
* On 64bit 14.04: did not install ia32-libs, nor the alternaive: "sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386", as it seems that newer version of the 32bit compiler were there already.
* added dialout to user group (and a logout - login cycle to implement)
* add ''dialout'' to user group (and a logout - login cycle to implement)
  sudo usermod -a -G dialout $USER
  sudo usermod -a -G dialout $USER
====Prerequisites for ground-control====
* QT is installed as version 4.8, but vesion 5.2+ is needed, so install:
sudo apt-get install qtcreator qttools5-dev qtbase5-dev qt5-default qtdeclarative5-dev libqt5serialport5-dev libqt5svg5-dev libqt5webkit5-dev libsdl1.2-dev build-essential libudev-dev
* qgroundcontrol can integrate with googleearth (on 64bit platform only?), so maybe you should install googleearth (the last line is probably another version, but is suggested by the "make-googleearth-package".
Further espeak and OpenSceneGraph should add further functionality.
sudo apt-get install lsb-core
sudo apt-get install espeak libespeak-dev
sudo apt-get install libopenscenegraph-dev
sudo apt-get install googleearth-package
make-googleearth-package
sudo dpkg -i googleearth_6.0.3.2197+1.1.0-1_i386.deb


====Ground control====
====Ground control====
Line 84: Line 107:
  git submodule update
  git submodule update
The last two lines allow other repositories to me in the same tree as groundcontrol and adds a mavlink/c_library from another git repository.
The last two lines allow other repositories to me in the same tree as groundcontrol and adds a mavlink/c_library from another git repository.
* QT is installed as version 4.8, but vesion 5.2+ is needed, so installed:
 
sudo apt-get install qtcreator qttools5-dev qtbase5-dev qt5-default qtdeclarative5-dev libqt5serialport5-dev libqt5svg5-dev libqt5webkit5-dev libsdl1.2-dev build-essential libudev-dev
<i>Note that the newest versions does not compile on Ubuntu 14.04 LTS (QT5.3 is missing). One solution is to use the "stable" branch of the ground control. Switch to this by issuing:</i>
* qgroundcontrol can integrate with googleearth (on 64bit platform only?), so maybe you should install googleearth (the last line is probably another version, but is suggested by the "make-googleearth-package".
  git checkout -t origin/Stable_V2.2
  sudo apt-get install lsb-core
 
sudo apt-get install googleearth-package
<i>Note also that in some versions there is an error in <tt>qgroundcontrol/libs/mavlink/include/mavlink/v1.0/common/common.h</tt>. Change <tt style="color:red">MAV_AUTOPILOT_RESERVED=1</tt> to <tt style="color:green">MAV_AUTOPILOT_PIXHAWK=1</tt>.</i>
make-googleearth-package
 
sudo dpkg -i googleearth_6.0.3.2197+1.1.0-1_i386.deb
* Make the needed Makefile, and compile
* Make the needed Makefile, and compile
  qmake
  qmake
  make
  make -j3
* Testrun the control application and connect the pixhawk
* Testrun the control application and connect the pixhawk
  ./release/qgroundcontrol
  ./release/qgroundcontrol


====PX4 firmware====
====Prerequisites for PX4 firmware====


* install arm compiler gcc-arm-none-eabi:
* install arm compiler gcc-arm-none-eabi:
  sudo apt-get install gcc-arm-none-eabi
  sudo apt-get install gcc-arm-none-eabi
* Get the px4 firmware from
This is likely version 4.8, but version 4.8 has an error for this arm processor, so version 4.7 needs to be installed and made available on the PATH. See http://pixhawk.org/dev/toolchain_installation_lin tool installation a bit down for all Linux distros.
git clone https://github.com/PX4/Firmware.git px4
* try a compile of nuttx (is fetched as part of the make command)
cd px4
make help
make archives
* make help is just to show compile options, then make the pixhawk firmware
make
* this gave for me an "Unsupported version of arm-none-eabi-gcc, found: 4.8.2 instead of 4.7.x.  Stop"
This seems to be required - see http://pixhawk.org/dev/toolchain_installation_lin tool installation a bit down for all Linux distros.
I tried to use the 4.8 version by editing the ''makefiles/toolchain_gnu-arm-eabi.mk'' (from 4.7 to 4.8), it compiled after fixing an issue for canbus by adding ''#define UAVCAN_IMPLEMENT_PLACEMENT_NEW 1'' where the compile failed, but the produced image did not run.
* if the version 4.8 is not fixed, then get the older version 4.7 and add it to the $PATH as first thing:
* if the version 4.8 is not fixed, then get the older version 4.7 and add it to the $PATH as first thing:
  cd ~
  cd ~
Line 120: Line 132:
  . ~/.profile
  . ~/.profile


* Compile again
* If upload to pixhawk gives an error like:
make
Then it compiled for me
 
* Upload to pixhawk
make upload px4fmu-v2_default
this gave:
  ...
  ...
  ==========================================================================================================
  ==========================================================================================================
Line 136: Line 142:
* The modemmanager conflicts, so remove it
* The modemmanager conflicts, so remove it
  sudo apt-get remove modemmanager
  sudo apt-get remove modemmanager
* then again
 
 
====PX4 firmware and Nuttx operating system====
 
* Get the px4 firmware from
git clone https://github.com/PX4/Firmware.git px4
* try a compile of nuttx (is fetched as part of the make command) - see ''make help'' to see compile options
cd px4
make archives
make px4fmu-v2_default
* then upload to the pixhawk (PX4)
  make upload px4fmu-v2_default
  make upload px4fmu-v2_default
This seems to finish as it should:
This should finish like:
  erase...
  erase...
  program...
  program...
  verify...
  verify...
  done, rebooting.
  done, rebooting.
But the pixhawk will not not generate the /dev/ttyACM0 post that qgroundcontrol uses for communication (nor any communication on serial port)
* qgroundcontrol cam make a default firmware upgrade, and this makes the pixhawk back in operational state, with an image fetched on the net. (Requires a hard reset of the pixhawk, before qgroundcontrol finds the device).


* '''Øv''' - but don't give up
* The image - ./Build/px4fmu-v2_default.build/firmware.px4 can also be uploaded using ''qgroundcontrol'' - when I tried the upload failed twice before success.
 
====New code====
 
* Now to modifying the code:
Follow recipy at http://pixhawk.org/dev/px4_simple_app
 
/Christian (24/08/2014)
 
===Configure===
 
In the pixhawk firmware tree goto /ROMFS/px4fmu_common/init.d, here the file 7010_hexakopter_+ is created
 
cd ROMFS/px4fmu_common
cat 7010_hexakopter_+
#!nsh
#
# Generic 10" Hexa + geometry
# platform is MicroKopter hexakopter with standard I2C motor controllers
#
# Christian Andersen <jca@elektro.dtu.dk>
#
sh /etc/init.d/rc.mc_defaults
# We only can run one channel group with one rate, so set all 8 channels
set PWM_OUTPUTS 12345678
set MIXER FMU_hexa_+
#set USE_IO no
set OUTPUT_MODE mkblctrl
set MKBLCTRL_MODE +
 
and in rc.autostart the following lines are added
 
if param compare SYS_AUTOSTART 7010
then
sh /etc/init.d/7010_hexakopter_+
fi
 
This enables the configuration for hexakopter motorcontroller
Now this configuration should be enabled:
Compile and upload the files:


* I tried a recompile of nuttx - maybe with version 4.7 this time - nuttx do not complain about the compiler version.
make distclean
make archives
  make px4fmu-v2_default
  make px4fmu-v2_default
  make upload px4fmu-v2_default
  make upload px4fmu-v2_default
The upload worked :)


* The image - ./Build/px4fmu-v2_default.build/firmware.px4 can also be uploaded using ''qgroundcontrol'' - when I tried the upload failed twice before success.
This will put the rc.autostart and 7010_hexakopter_+ files in /etc/init.d on the pixhawk.
 
* Now this configuration should be enabled.
Start qgroundcontrol.
Connect to the pixhawk (top-right).
 
In the "tool widgets" menu click "onboard parameters". Increase the widget if it is too small.
 
Find the parameter SYS, and change the SYS_AUTOSTART value to 7010.
 
Press "write ROM" to save on pixhawk.
 
* To do some debugging during startup it is neccesary to connect serial connection to e.g. putty.
Connect the serial cable (serial to USB) to serial 4/5, and open the connection with putty.
 
* reboot the pixhawk.
The serial connection will output debug messages as it reboots, and will report errors.
 
* motor test
 
To test the connection to the motors use the serail connection


* Now to modifying the code:
mkblctrl -t
Follow recipy at http://pixhawk.org/dev/px4_simple_app


/Christian (24/08/2014)
The motors should spin up (at a low speed) in CV order starting with the front motor.


===Arduflight recipy===
===Arduflight recipy===


This is part of the instructions using ardupilot rather than qgroundcontrol.
This is part of the instructions is using ardupilot rather than qgroundcontrol.
- this is not needed if you followed the instructions above.


Log of actions to use pixhawk on hexakopter:
Log of actions to use pixhawk on hexakopter:
Line 185: Line 256:


  make px4-v2-upload
  make px4-v2-upload


==== PIXHAWK (ardupilot) GUI ====
==== PIXHAWK (ardupilot) GUI ====


Get the QT4 based GUI for the (ardupilot) pixhawk by
Get the QT4 based GUI for the (ardupilot) pixhawk by
Line 205: Line 279:


  cd apm_planner
  cd apm_planner
  qmake
  qmake qgroundcontrol.pro
make -j3


This takes some time
This takes some time
Line 212: Line 287:


  cd release
  cd release
  ./apm_planner
  ./apmplanner2

Latest revision as of 08:54, 4 September 2015

Software configuration for Microkopter

Hexacopter with MikroKopter flight controller

How to compile and install software in hexacopter The modifications work best under windows, but some support exist for linux too.

This description is for windows (XP)

Get software

The supplier URL is http://www.mikrokopter.de/ucwiki/en/MikroKopter?action=show&redirect=FrontPage

To replace the software the following is needed:

  • the source code - using SVN
  • WinAvr with GCC compiler version 3.xx (newer compiles produce to slow code)
  • kopter-tool to install the software

SVN checkout

Install TortoiseSVN from http://sourceforge.net/projects/tortoisesvn/ if you do not have an SVN client already.

Do a SVN checkout from http://mikrokopter.de/mikrosvn/FlightCtrl/ to get the sourcevode for the flight controler (for other software - e.g. motor controller, the SVN URL is at http://www.mikrokopter.de/ucwiki/MikroKopterRepository)

WinAVR

WinAvr version WinAVR-20060421 comes with gcc version 3.4.6 - wich is OK. gcc version 4.x until at least 4.5.1 will not work (CPU will get overloaded and will - at least - no longer talk to kopter-tool.

  • Open programmers notepad and open a project for the newest branch in the flight controller repository. It already has a project file for programmers notepad. And a makefile for avr-gcc.
  • Compile the project (Tools->make_All) and it should make a *.hex file for one of the Flight-ctrl boards (currently default is version 2.0 with an atMEGA644 processor (Flight-ctrl 2.1 has an atMEGA1284p processor, and one of the first lines in the makefile needs to be changed)

Install new software

To install the newly compiled software use Kopter-tool. The copter has a bootloader installed, and the kopter-tool can switch to the bootloader while running.

Unpack the zip file, and the Kopter-tool is ready. It may be an idea to make a shortcut on the desktop.

  • Connect the helicopter to the PC (Flight-ctrl 5V rs232 port using the USB to 5v-RS232

device from Microkopter. Leave the helocopter battery off. And power the Flight-ctrl processor by connecting the two patch pins on the USB to 5v-RS232 board.

Assuming the USB-to-serial device is known to the PC. The PC now has a new com-port. Make sure this has a number less than com10, as it seems than Kopter-tool will only allow one-digit numbers.

  • Start the Kopter-tool. It will probably say "no connection".

Click on the "Firmware update and Terminal" buttom. From here change the com-port as appropriate. Now a few messages should arrive from the helicopter.

  • Press the "Software Update" and find the compiled *.hex-file.

The newly compiled software should now load.

If the load fails, then try again (at times some data is lost).

If the helicopter fails to run (totally wrong code, or upload-error), then the bootloader (most likely) still works. But the upload needs a special procedure.

Dead kopter bootload: Remove the jumper that powers the Flight-ctrl (on the USB to 5v-RS232 converter), start a new software update, and while it shown dots "...." on the terminal window, replace the jumper, and the boot-loader should be catched before it starts the faulty software. If it fails, retry.


Pixhawk

This section is for a configuration, where MikroKopter flight controller is replaced with the more open source pixhawk px4 controller.

This section goes through the software installation (and configuration - once it is in place). The configurations aren not - as yet - available in any repository, so follow the instructions below to make your own configuration.

Raw pixhawk installation

From page https://pixhawk.org/dev/toolchain_installation_lin on a 32 and 64 bit 14.04 ubuntu (well kubuntu, but this should not matter much)

  • installed dependencies - no problem
sudo apt-get install python-serial python-argparse openocd \
   flex bison libncurses5-dev autoconf texinfo build-essential \
   libftdi-dev libtool zlib1g-dev genromfs git-core wget
  • On 64bit 14.04: did not install ia32-libs, nor the alternaive: "sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386", as it seems that newer version of the 32bit compiler were there already.
  • add dialout to user group (and a logout - login cycle to implement)
sudo usermod -a -G dialout $USER


Prerequisites for ground-control

  • QT is installed as version 4.8, but vesion 5.2+ is needed, so install:
sudo apt-get install qtcreator qttools5-dev qtbase5-dev qt5-default qtdeclarative5-dev libqt5serialport5-dev libqt5svg5-dev libqt5webkit5-dev libsdl1.2-dev build-essential libudev-dev
  • qgroundcontrol can integrate with googleearth (on 64bit platform only?), so maybe you should install googleearth (the last line is probably another version, but is suggested by the "make-googleearth-package".

Further espeak and OpenSceneGraph should add further functionality.

sudo apt-get install lsb-core
sudo apt-get install espeak libespeak-dev
sudo apt-get install libopenscenegraph-dev
sudo apt-get install googleearth-package
make-googleearth-package
sudo dpkg -i googleearth_6.0.3.2197+1.1.0-1_i386.deb

Ground control

Ground control is the main configuration application for pixhawk, also used for uploading new firmware for to the pixhawk, so it is needed.

git clone git://github.com/mavlink/qgroundcontrol.git
cd qgroundcontrol
git submodule init
git submodule update

The last two lines allow other repositories to me in the same tree as groundcontrol and adds a mavlink/c_library from another git repository.

Note that the newest versions does not compile on Ubuntu 14.04 LTS (QT5.3 is missing). One solution is to use the "stable" branch of the ground control. Switch to this by issuing:

git checkout -t origin/Stable_V2.2

Note also that in some versions there is an error in qgroundcontrol/libs/mavlink/include/mavlink/v1.0/common/common.h. Change MAV_AUTOPILOT_RESERVED=1 to MAV_AUTOPILOT_PIXHAWK=1.

  • Make the needed Makefile, and compile
qmake
make -j3
  • Testrun the control application and connect the pixhawk
./release/qgroundcontrol

Prerequisites for PX4 firmware

  • install arm compiler gcc-arm-none-eabi:
sudo apt-get install gcc-arm-none-eabi

This is likely version 4.8, but version 4.8 has an error for this arm processor, so version 4.7 needs to be installed and made available on the PATH. See http://pixhawk.org/dev/toolchain_installation_lin tool installation a bit down for all Linux distros.

  • if the version 4.8 is not fixed, then get the older version 4.7 and add it to the $PATH as first thing:
cd ~
wget https://launchpadlibrarian.net/174121628/gcc-arm-none-eabi-4_7-2014q2-20140408-linux.tar.bz2
tar -jxf gcc-arm-none-eabi-4_7-2014q2-20140408-linux.tar.bz2
exportline="export PATH=$HOME/gcc-arm-none-eabi-4_7-2014q2/bin:\$PATH"
if grep -Fxq "$exportline" ~/.profile; then echo nothing to do ; else echo $exportline >> ~/.profile; fi
. ~/.profile
  • If upload to pixhawk gives an error like:
...
==========================================================================================================
WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)
==========================================================================================================
Loaded firmware for 9,0, waiting for the bootloader...
attempting reboot on /dev/serial/by-id/usb-3D_Robotics_PX4_FMU_v2.x_0-if00...
attempting reboot on /dev/serial/by-id/usb-3D_Robotics_PX4_FMU_v2.x_0-if00...
  • The modemmanager conflicts, so remove it
sudo apt-get remove modemmanager


PX4 firmware and Nuttx operating system

  • Get the px4 firmware from
git clone https://github.com/PX4/Firmware.git px4
  • try a compile of nuttx (is fetched as part of the make command) - see make help to see compile options
cd px4
make archives
make px4fmu-v2_default
  • then upload to the pixhawk (PX4)
make upload px4fmu-v2_default

This should finish like:

erase...
program...
verify...
done, rebooting.
  • The image - ./Build/px4fmu-v2_default.build/firmware.px4 can also be uploaded using qgroundcontrol - when I tried the upload failed twice before success.

New code

  • Now to modifying the code:

Follow recipy at http://pixhawk.org/dev/px4_simple_app

/Christian (24/08/2014)

Configure

In the pixhawk firmware tree goto /ROMFS/px4fmu_common/init.d, here the file 7010_hexakopter_+ is created

cd ROMFS/px4fmu_common
cat 7010_hexakopter_+
#!nsh
#
# Generic 10" Hexa + geometry
# platform is MicroKopter hexakopter with standard I2C motor controllers
#
# Christian Andersen <jca@elektro.dtu.dk>
# 

sh /etc/init.d/rc.mc_defaults
# We only can run one channel group with one rate, so set all 8 channels
set PWM_OUTPUTS 12345678

set MIXER FMU_hexa_+
#set USE_IO no
set OUTPUT_MODE mkblctrl
set MKBLCTRL_MODE +

and in rc.autostart the following lines are added

if param compare SYS_AUTOSTART 7010
then
	sh /etc/init.d/7010_hexakopter_+
fi

This enables the configuration for hexakopter motorcontroller Now this configuration should be enabled: Compile and upload the files:

make px4fmu-v2_default
make upload px4fmu-v2_default

This will put the rc.autostart and 7010_hexakopter_+ files in /etc/init.d on the pixhawk.

  • Now this configuration should be enabled.

Start qgroundcontrol. Connect to the pixhawk (top-right).

In the "tool widgets" menu click "onboard parameters". Increase the widget if it is too small.

Find the parameter SYS, and change the SYS_AUTOSTART value to 7010.

Press "write ROM" to save on pixhawk.

  • To do some debugging during startup it is neccesary to connect serial connection to e.g. putty.

Connect the serial cable (serial to USB) to serial 4/5, and open the connection with putty.

  • reboot the pixhawk.

The serial connection will output debug messages as it reboots, and will report errors.

  • motor test

To test the connection to the motors use the serail connection

mkblctrl -t

The motors should spin up (at a low speed) in CV order starting with the front motor.

Arduflight recipy

This is part of the instructions is using ardupilot rather than qgroundcontrol. - this is not needed if you followed the instructions above.

Log of actions to use pixhawk on hexakopter:

starting with the configuration from Søren Hansen, giving the directories in

px4src/ardupilot  
px4src/PX4Firmware
px4src/PX4NuttX
cd  px4src/ardupilot

Make the version for PX

cd ArduKopter
make configure
make px4-v2

Once finished it can be installed if the pixhawk is connected by

make px4-v2-upload


PIXHAWK (ardupilot) GUI

Get the QT4 based GUI for the (ardupilot) pixhawk by

1. Make sure these packages are installed

sudo apt-get install phonon libqt4-dev libqt4-opengl-dev \
 libphonon-dev libphonon4 phonon-backend-gstreamer \
 qtcreator libsdl1.2-dev libflite1 flite1-dev build-essential \
 libopenscenegraph-dev libssl-dev libqt4-opengl-dev libudev-dev \
 libsndfile1-dev libqt4-sql-sqlite

2. getting the software from git:

git clone https://github.com/diydrones/apm_planner.git apm_planner

3. go to this directory and configure and make

cd apm_planner
qmake qgroundcontrol.pro
make -j3

This takes some time

then go to the release directory and run

cd release
./apmplanner2