Mathieu Goedhart
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Deployment/Development Manual ## API ### Backend #### Production ```bash cd backend npm install npm start ``` #### Tests (IntelliJ is vereist) Open backend als project in IntelliJ IDEA. In het mapje `tests` staan 2 bestanden, dit zijn intellij api test bestanden die je kunt uitvoeren door er één te openen en om dan op de `Run all requests in file` te klikken bovenaan het scherm. Dan selecteer je de `Run with 'dev' environment`. #### Development ```bash cd backend npm install npm run dev ``` Dit start de server met nodemon. ### Swagger Als eerst heb je een account nodig op <https://swagger.io/>. Wanneer je vervolgens inlogd met je account wordt je doorverwezen naar swaggerhub. Hier kan je zoeken naar de API documentation. Hier is een link naar onze API documentatie: <https://app.swaggerhub.com/apis/quentin-correia/H20-UN_Systeem/1.0.0> Je kan het niet bewerken maar je kan wel de yaml kopiëren en plakken in je eigen project. Bij de API documentatie kan je de documentatie downloaden via Export->Documentatie en dan dynamic-html, html of html2. Wij hebben zelf gekozen voor html2 in onze project. ## TTN Maak een account aan bij The Things Network. Ga naar de console en registreer hier een nieuw apparaat. Voer een "Application ID" in en druk op "Add application". Nu krijg je de application overvies pagina te zien. Hier is onder andere de "Default key" te vinden. Bij de tab "Devices" kan je de laird registreren. voer een "Device ID" in. De andere velden kunnen op "generate worden gezet". Nu is de Laird geregistreerd en kan deze worden gebruikt. ## Laird #### Vereisten * Laird RM186-SM * UwTerminalX * Notepad++ (optioneel) * Drivers zijn te vinden in de [laird folder](/laird) Alles wat je nodig hebt om met de Laird te werken (op een Windows apparaat) is in de laird folder te vinden, zoals de drivers en de UwTerminalX. Om ons programma dat op de laird staat uit te voeren moet het commando `combined` worden ingevoerd en uitgevoerd. ### Bluetooth Als we vanaf noble een stukje data wordt verstuurd kan dit maar worden ontvangen met maximaal 20 bytes, hierom hebben we in noble de berichten opgebroken in stukjes van 20 bytes of kleiner. Wanneer deze zijn overgekomen sturen we er een send achter aan zodat de laird weet dat we klaar zijn met het pakketje. ### LoRaWAN In UwTerminal terwijl de laird verbonden is en de port open is moeten de volgende commands worden uitgevoerd: * at+cfgex 1010 "AppEui" * at+cfgex 1011 "DevEui" * at+cfgex 1012 "AppKey" Deze kunnen worden gevonden op de Device Overview pagina van de laird. Om te checken of de configuratie is gelukt "at+cfgex 10xx?". In notepad++ kunnen scripts worden gemaakt voor de laird in de smartbasic taal. Deze scripts zijn ".sb". Om een script uit te voeren kan dit via UwTerminal worden gedaan, open UwTerminal terwijl de laird is verbonden via usb. druk rechtsboven op "Open Port". Nu kan in het terminal tabje op rechter muisknop gedrukt worden. Druk op "XCompile + Load + Run" om een scirpt uit te voeren. In de "Data" tab van TTN is te zien of de laird ## UI ### Backend #### Production ```bash cd ui npm install npm start ``` #### Tests ```bash cd ui npm install npm run test ``` #### Development ```bash cd ui npm install npm run dev ``` Dit start de server met nodemon. ##### Bestandsstructuur - src/ - static/ - \[static_files] - views/ - partials/ - html (handlebar) - sass/ - stylesheets - main.hbs - \[modules].js - test/ - jest tests - package.json In src staat al het programmatuur voor de ui, beide frontend en backend. Al de modules (backend scripts) staan in de root van de src folder. De website met js, html, etc. staan allemaal in de views folder, geschreven in scss en handlebarjs. ##### Packet Splitting ```javascript // data is type of Buffer try { for (let i = 0; i < data.length; i += 20) { /* * Knip een gedeelte van de buffer, van i tot i + 20 * Dus 0 - 19 : 20 - 39 */ const packet = data.slice(i, i + 20); // Schrijf het gedeelte op de laird await asyncWrite(packet); } /* * Na alle in delen te hebben opgestuurd, * moet de laird weten of het doorgestuurd moet worden * naar TTN. * Dit doen we door een 'send' bericht te sturen. */ await asyncWrite(Buffer.from('send', 'utf-8')); } catch (err) { // Error handling return reject(err); } ``` In dit for loopje breken we een packet op dat langer kan zijn dan 20 bytes in stukken van 20 bytes, omdat dit de maximale grootte is wat verstuurd mag worden over bluetooth. ### Frontend De frontend is te bereiken op <http://localhost:8080/> Er zijn 3 tabs beschikbaar: Home, Logs en Console. In Home kun je de kaart van nederland zien met data van drones erop gepinned. In Logs staan alle berichten in een table die zijn binnengekomen van de drones. Dit is handig om alles duidelijk weer te geven op tijd. In Console kun je berichten naar de drones sturen en ook berichten naar de laird sturen. ## Heltec #### Vereisten: * Arduino IDE 1.8.13 * Heltec ESP 32 * Heltec Drivers #### Boardmanager URLs en bibliotheken: 1) Open de Arduino IDE 2) Open de voorkeuren. 3) Plak volgende URLs onder het kopje 'Meer boardmanager URL's' ``` https://resource.heltec.cn/download/package_heltec_esp32_index.json,http://resource.heltec.cn/download/package_heltec_esp8266_index.json ``` Er zal een melding verschijnen dat er nieuwe boardmanagers beschrikbaar zijn. Klik hier op 'updaten'. **Biblioteken downloaden:** Ga naar hulpmiddelen -> biblioteken beheren. Typ 'Heltec esp 32' en klik vervolgens op 'Heltec ESP 32 Dev Boards', kies voor de nieuwste versie en daarna voor installeren. #### Heltec Drivers (Windows) Voor de Heltec kun je de CP210x Universal Windows Driver gebruiken. De drivers zijn de downloaden op onderstaande website: ``` https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers ```` ## Ubuntu (Python, MavServer, PX4) **Vereisten:** * Ubuntu 20.04 * Python 3 (standaard in Ubuntu 20.04) * 35+ GB schrijfruimte #### Installatie **De toolchain installeren** Clone de PX4 toolchain software naar een directory naar keuze. Wij hebben het project naar de Documenten folder gecloned. ```bash git clone https://github.com/PX4/PX4-Autopilot.git --recursive ``` Voer onderstaande commando uit om de toolchain te installeren: ```bash bash ./PX4-Autopilot/Tools/setup/ubuntu.sh ``` Voer vervolgens onderstaande commando uit om Gazebo te compileren: ```bash make px4_sitl gazebo ``` Omdat het aansturen van meerdere drones niet standaard wordt ondersteund in MavSDK voor Python dient de MavSDK server development versie gedownload te worden. Let op: Het is een vereisde om de mavSDK repo te clonen naar de root van de Home folder van de inglogde gebruiker voor een correcte werking. 1) Clone en open de repo van MAVSDK: ```bash git clone https://github.com/mavlink/MAVSDK-Python --recursive cd MAVSDK-Python ``` 2) Installeer de vereisten: ```bash cd proto/pb_plugins pip3 install -r requirements.txt cd ../.. pip3 install -r requirements.txt -r requirements-dev.txt ``` 3) Genereer de code: ```bash ./other/tools/run_protoc.sh ``` 4) Bouw en installeer het pakket lokaal: ```bash python3 setup.py build pip3 install -e . ``` *Meer hulpbronnen:* https://github.com/mavlink/MAVSDK-Python https://github.com/mavlink/MAVSDK/issues/931 #### Debug mode Om de code te kunnen testen zonder UI en Heltec hebben wij een 'debug modus' toegevoegd aan de code. Debug modus kan uitgezet worden door in Main.py de boolean debug op False te zetten. **Commando's om het programma te starten:** Als allereerst moet je via de terminal in Ubuntu navigeren naar de directory waar PX4 inzit: ```bash cd ~/.../PX4-Autopilot ``` Daar voer je dan de volgende commando uit: ```bash Tools/gazebo_sitl_multiple_run.sh -n 2 -t px4_sitl_default ``` De -2 staat dan voor het aantal drones dat je wilt hebben. Als je bijvoorbeeld -4 neerzet in plaats van -2 dan zullen er 4 drones zijn. Wanneer je dit commando hebt uitgevoerd zal Gazebo van zelf starten. **Python** Nu kan je het Python project runnen. Dit doe je door main.py te runnen. Wanneer je dit doet wordt er gevraagd hoeveel drones je wilt hebben. Dit aantal moet gelijk zijn aan het aantal drones die je in de commando hebt aangegeven. Vervolgens wordt het programma opgestart en moet je heel even wachten. Na wat wachten wordt er gevraagd om een hex. Wanneer je een hex hebt ingevoerd zullen de drones vertrekken naar de coördinaten. De allereerste drone zal gaan naar de orginele coördinaten van de hex. De resterende drones zullen naar coördinaten gaan in een cirkel met een radius van 1km om de orginele coördinaten. **Cirkel punten berekenen** Hier onder staat het stukje code dat de punten berekent in een gebied van de cirkel om de orginele coördinaten ```python def calculate_circle_points(self, lat, long, circlePoints, drone_size): # inputs radius = 1000.0 # m - the following code is an approximation that stays reasonably accurate for distances < 100km centerLat = lat # latitude of circle center, decimal degrees centerLon = long # Longitude of circle center, decimal degrees # parameters N = drone_size # number of discrete sample points to be generated along the circle # generate points for k in xrange(N): # compute angle = math.pi * 2 * k / N dx = radius * math.cos(angle) dy = radius * math.sin(angle) point = {'lat': centerLat + (180 / math.pi) * (dy / 6378137), 'long': centerLon + (180 / math.pi) * (dx / 6378137) / math.cos(centerLat * math.pi / 180)} # add to list circlePoints.append(point) ``` De parameters lat en long staan voor latitude en longitude. De circlePoints is de lijst waar uiteindelijk de nieuwe punten aan worden toegevoegd. De drone_size zijn de aantal drones die naar een cirkel punt moeten gaan. De radius is 1km. Er wordt door N gelooped en de cirkel punten worden berekent. 6378137 is een vaste waarde dat wordt gebruikt bij deze berekeningen. Deze cirkel punten worden dan toegevoegd aan de circlePoints lijst.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully