Published February 19, 2019 | Version v1
Software Open

Ring communication of Pixhawk4 modules for multidrone control

Description

This software bundle has been developed as part of the CODISAVA project funded by the ELKATEK 2018 program of the Basque Government by members of the Computational Intelligence Group of the UPV/EHU (www.ehu.es/ccwintco)

The idea of this module is to operate in a slave pixhawk4 device connected to a master controller and other 3 slaves forming a ring structure. The master controller sends the commands for all 3 slaves, they dispatch the messages to the following slave and the local setpoint controller and substitute their own commands with their sensorial readings to be used as feedback by the master controller when it gets the message back after a full round of communication.

1. Controllers
This module (`/src/examples/codisava/`) implements two different controllers:
    - Slaves (`codisava slave id=[1..4] <debug> <non-blocking> <no-feedback>`)
    This controller receives messages from the master controller or the previous slave via the 'input port' and dispatches them to either the actuator or the next slave in the chain ('output port'). It also reads data from the sensors and sends them to the master via the 'input port' (feedback). Switches:
     - Fake master (`codisava send-data  <debug> <non-blocking> <no-feedback>`)
    This simple controller sends mock messages via the 'output port' to the slaves and reads the feedback from them ('input port'). Used for testing.

    Meaning of the parameters:
      -_debug_: enables console output
      -_non-blocking_: forces use of non-blocking IO. Currently not working
      -_no-feedback_: disables the use of feedback. Sensors are simply not read

    The name of the input/output ports and the baud-rate is configured in the file `codisava.h`.
    The module can be started automatically without using the shell by editing `home/Firmware/boards/px4/fmu-v5/init/rc.board`

2. Message format

   The messages are of two types: ControlMessage (master -> slaves) and FeedbackMessage (slaves -> master). They are defined in `serial_port.h`:


   ```
   #define STX 2
   #define ETX 3

   struct CodisavaMessage
   {
    unsigned char stx = STX;

    //before reaching destination:                                               data[i]= [pitch    roll      throttle]
    //after reaching destination the slave overwrites data with feedback data:   data[i]= [pitch    roll      throttle]
    float payload[4][3];

    unsigned char checksum;
    unsigned char etx = ETX;
   };
   ```
   The master controller should fill data with the commands for each slave. The first index is the slaves' index ([0..3]) and the second: 0->yaw, 1-> pitch, 2->roll, 3->thrust.
   As each slave receives the message, gets its commands from it and substitutes the commands with the sensor readings: 0->yaw, 1->pitch, 2,3-> unused.


3. Serial port communications
Communications (`serial_port.h/.cpp`) are blocking by default.
The connections should be made in series (using cables with swapped Rx/Tx):
   ```
   Master (output) -> Slave#1 (input)
   Slave#1 (output) -> Slave#2 (input)
   Slave#2 (output) -> Slave#3 (input)
   Slave#3 (output) -> Slave#4 (input)
   ```
   Any message going from the master to the slave#4 must go through slaves#1, 2, and 3.

 

####Instrucciones de instalación

  1. Download cygwin toolchain
    Download and install from here  (select "clone firmware repository")
  2. Compile firmware and upload
    • Go to folder (home)/firmware
    • make px4_fmu-v5 upload
  3. Use the mavlink shell to interact with the px4:
    • Before you can the mavlink shell (python Tools/mavlink_shell.py)
      • Install python2-devel:
        • (home)/toolchain/cygwin64/setup-x86_64.exe -> install from internet -> next...
        • browse for your cygwin dir (above)
        • search for python2-devel and select "Source"
        • next
      • Install pymavlink:
        • (home)->run_console.bat
        • pip2 install --upgrade pip
        • pip2 install pymavlink
    • Run mavlink shell:
      • (home)->run_console.bat
      • Firmware/Tools/mavlink_shell.py
      • python Tools/mavlink_shell.py
  4. Download the zip file and copy the contents in folder (home)/firmware/src/examples

Files

codisava.zip

Files (13.3 kB)

Name Size Download all
md5:58044890d3bf2297a96213b6b95751a0
13.3 kB Preview Download