infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 6 of 6

Thread: Copter Simulator

  1. #1
    Beginner Beginner PhilippGuehring is on a distinguished road
    Join Date
    May 2016
    Posts
    16
    Points
    78.75

    Copter Simulator

    I am not sure, whether I should post in english or german. If anyone needs an english translation, please add a comment, and I will provide a translation.

    Ich hab jetzt geschafft, einen Quadrocopter Simulator zu entwickeln:

    Benötigt wird Blender (von www.blender.org installieren) und dann
    http://www2.futureware.at/~philipp/K.../Copter6.blend
    entweder mit dem blenderplayer starten oder in Blender öffnen und dann im Hauptfenster "P" drücken.

    Steuerung:
    + oder W: Mehr Schub auf alle 4 Motoren
    - oder S: Weniger Schub auf alle 4 Motoren
    Cursor Tasten:
    Cursor Links: Weniger Schub auf die linken Motoren, mehr Schub auf die rechten Motoren damit er Copter nach links fliegt
    Cursor Rechts: Weniger Schub auf die rechten Motoren, mehr Schub auf die linken Motoren
    Cursor Oben: Weniger Schub auf die hinteren Motoren, mehr Schub auf die vorderen Motoren
    Cursor Unten: Weniger Schub auf die vorderen Motoren, mehr Schub auf die hinteren Motoren
    A: Drehung nach Links
    D: Drehung nach Rechts

    Die Steuerung ist relativ schwierig, da man direkt die Motoren steuert, ohne einer intelligenten Steuerung, die den Copter stabil hält.
    Aber ich denke daß es ein erstes gutes Beispiel, um zu lernen, was eine gute Steuerung-Software zu leisten hat um den Copter stabil zu halten, und über die physikalischen Flugdynamik.

    Als nächstes will ich die Widefield Software an den Simulator anbinden, um die Widefield Software im Simulator testen zu können:
    Als ersten Schritt habe ich von Blender die aktuelle Höhe des Copters aus der 3D Simulation ausgelesen und in das Height Feld geschrieben,
    und dann daraus mit einer linearen Annäherung den zu simulierenden Luftdruck berechnet (pressure).
    Dann will ich noch die Lage von Blender auslesen und damit den Lagesensor und Luftdurcksensor in der Widefield Software simulieren, und die Motor-Ansteuerung die die Widefield Software berechnet an die 3D Simulation im Blender übertragen.

  2. #2
    Beginner Beginner PhilippGuehring is on a distinguished road
    Join Date
    May 2016
    Posts
    16
    Points
    78.75
    Ich habe jetzt eine neue Version vom Quadrocopter Simulator entwickelt:
    http://www2.futureware.at/~philipp/K.../Copter9.blend

    Als Umgebung habe ich jetzt das Roboter-Challenge Szenario nachgebaut (2 Stangen, Schleife am Boden).
    Dann habe ich noch ein paar Kameras eingebaut, mit den Tasten 1,2,3,4 kann man während der Simulation
    zwischen den verschiedenen Kameras wechseln.
    Eine der Kameras ist unten am Quadrocopter befestigt und schaut direkt nach unten, um die Kanupolo Boote zu beobachten
    oder der RoboChallenge Schleife zu folgen.
    Am hinteren Rand des Feldes habe ich 2 Bildschirme aufgestellt, die die Kamerabilder von 2 der Kameras anzeigen.
    Über den Namen der Bildschirme wird gesteuert, welche Kamera dargestellt wird, wenn ihr eine andere Kamera darstellen wollt, einfach den Bildschirm umbenennen.

    Zum Trainieren der Bildverarbeitung kann die Simulation die Bilder einer Kamera per HTTP POST an die Bildverarbeitungs-Software schicken.
    (Server-seitig habe ich zur Zeit Code, der das Bild speichert und in PNG konvertiert, falls jemand Beispielcode braucht)
    Um das schicken zu aktivieren und deaktivieren, bitte die Taste 'I' drücken.

    Blender hat zur Zeit eine Einschränkung: Wenn man Kamerabilder speichern will, müssen sie auf eine Textur projeziert werden (also auf einem Bildschirm dargestellt werden)

    Die Copter Physik habe ich um die Rotation um die Z Achse erweitert, und für die Copter Steuerung
    die Tasten WASD zusätzlich zu den Cursortasten definiert, damit man mit 2 Händen gut steuern kann.
    W: Nach oben, S: Nach Unten, A: Drehung nach links, D: Drehung nach Rechts

  3. #3
    Beginner Beginner PhilippGuehring is on a distinguished road
    Join Date
    May 2016
    Posts
    16
    Points
    78.75
    I have ported the Widefield software to Linux now and prepared it for simulation.
    The last missing piece is the communication interface between the Blender copter simulation and the Widefield software.
    I would have liked to use ZeroMQ, but it's really hard to get it running inside Blender, since there are no native Python implementations yet.
    I think I will use UDP, if nobody has any better ideas.

  4. #4
    Beginner Beginner DanyDJ is on a distinguished road DanyDJ's Avatar
    Join Date
    Apr 2016
    Location
    Vienna
    Posts
    7
    Points
    85
    Hi Philipp,

    I´ve seen your status-update at the last Tele-Hase Event a few weeks ago. In the Video I´ve seen one of you using the Spectrum DX6i to control your Simulator.
    I´d like to ask one question:

    How did you manage to read the data coming from the DX6i? - I´m currently struggling with the analysation of the DSMX-data received from the DX6i.
    In this context I´ve come up with this code (Link), which reads the information coming from the DX6i.

    Current Status:
    Reading the serial Interface (UART) @ 115200 BAUD with 8N1 seems to be correct. Interpreting the data however is out of my know-how.
    We are using C/C++ and my python skills are unfortunatly not that good to understand what the different functions do...especially unpack()

    Thanks in advance for your help and have a nice day!
    Daniel




    EDIT:
    Unfortunatly had to reverse-engineer this on my own, but finaly got it. If someone needs Help in reading the Spectrum DSMX-Receiver don´t hesitate asking or sending me a PM or email.
    Last edited by DanyDJ; Sep 13th, 2016 at 01:00 AM. Reason: added information
    There are 10 types of people in this world. Those that understand binary and those that don't
    strtok() - You come in peace, but you go back in pieces.

  5. #5
    Beginner Beginner PhilippGuehring is on a distinguished road
    Join Date
    May 2016
    Posts
    16
    Points
    78.75
    Sorry for replying late.
    At first I took an Arduino and used a Arduino PPM library, and then parsed the output over USB-serial. But the problem there was that sometimes it gave completely wrong values, which resulted in spikes and random erratic behaviour of the copter.
    Perhaps it was some timing problem of the Arduino
    Then I bought a Spectrum Trainerport->USB converter for about 10 EUR, which provides the values as joystick over USB.
    I havent implemented the Joystick interface in my simulator yet, though, but I want to do that.
    The interface is not a serial / UART interface, it is a analog PPM signal, so you cannot decode it with a serial/UART decoder, I would say.
    My suggestion is to buy a PPM->USB converter.

  6. #6
    Beginner Beginner DanyDJ is on a distinguished road DanyDJ's Avatar
    Join Date
    Apr 2016
    Location
    Vienna
    Posts
    7
    Points
    85
    The DSMX-Receiver (Sattelite) we were handed comes with a AR6210. Sat. and AR6210 comunicate with eachother over a serial Interface with 115200 BAUD 8N1.
    In order to decode the Information sent it is necessary to read 16 byte and then do some shifting with the bytes. This aproach does not offer any failures for us.
    We ported this python script to C/C++ and it works fine without any failures.
    http://api.ning.com/files/kMyzkPYXBO...n/dx6i_info.py

    FYI: We first had to bind Sender and Receiver as usual, then we detached the AR6210 from the Sat. Afterwards its pretty easy to pin the 3 wires of the Sat.
    Red = 3.3V
    Black = GND
    Gray = Serial-Data (115200 8N1)

    Click image for larger version

Name:	e6_spm9645_dsmx_receiver.jpg
Views:	1
Size:	14.0 KB
ID:	2595
    (image from: http://www.horizonhobby.co.uk/aeroon...6-spm9645.html)

    Decoding works with standard C-Libraries such as fcntl and termios.
    Code:
    int n = read(handle, &input, sizeof(input));
            
                if(n>0)
                {
                    ReadBufRC[s] = input;
                    s++;
                    if(s==16)
                    {
                        for(i=0;i<16; i+=2)
                        {
                            chanID = ReadBufRC[i] >> 3;                    
                            data[chanID] = (ReadBufRC[i] & 0b111) << 8 | ReadBufRC[i+1];
                        }
                        
                        // asigning the gathered values to the corresponding variables                    
                        QuadCopter.SET_throttle (data[0]);
                        QuadCopter.SET_aileron  (data[1]);
                        QuadCopter.SET_elevator(data[2]);
                        QuadCopter.SET_rudder   (data[3]);
                        QuadCopter.SET_Gear     (data[4]);
                        
                        s=0;
                    }
    Up to know we just read one Character at the time, since we have not managed to read the 16 Characters on one time. read() just returns a max. of 8 Characters on one run. Nevertheless this snippet should visualize how we decoded the stream coming from the DMSX-Sat.
    The data array now contains int-Values between 0 and 2000 for each joystick. Selecting the right model on the Spectrum Sender, enables getting some of the switches on the Sender into some channels transmitted. In our case, we use the GEAR-Switch to change between autonomous flight mode and manual flight mode
    Last edited by DanyDJ; Sep 20th, 2016 at 02:24 AM. Reason: added information, added source for parsing gathered data
    There are 10 types of people in this world. Those that understand binary and those that don't
    strtok() - You come in peace, but you go back in pieces.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.