Se rendre au contenu
CTech Digital
  • Accueil
  • Services Odoo
  • Services d'IA
  • Contactez-nous
  • 0
  • Nederlands (BE) English (UK) Français
CTech Digital
  • 0
    • Accueil
    • Services Odoo
    • Services d'IA
    • Contactez-nous
  • Nederlands (BE) English (UK) Français

Implementing a JSON source

  • Tous les blogs
  • Daily blog
  • Implementing a JSON source
  • 6 juillet 2025 par
    CTech Metrology, Luc Wens

    Winsock include problem

    It's this fucker

    #error: WinSock.h has already been included

    To get rid of this annoying thing, include the next lines before all places where boost/asio.hpp is included

    #ifdef _WIN32
        // prevent winsock.h inclusion errors
        #define WIN32_LEAN_AND_MEAN
        #define _WINSOCKAPI_
        #include <winsock2.h>
        #include <ws2tcpip.h>
        #include <windows.h>
    #endif

    Added dataStructures.h

    This contains all the common data that was originally in ouster detect and in the 5G alert protocol.

    This is based on the Ouster Detect [see pdf]. Check chapter 8.

    Veld (Engels, uit bron) Type (uit bron) Units Beschrijving
           
    frame_count int64_t   Het aantal frames sinds het systeem is begonnen met het uitvoeren van objectlijsten. Deze waarde moet sequentieel zijn1.
    timestamp int64_t µsec 1/1/70 Tijdstempel van het moment waarop de laatste puntwolk arriveerde die heeft bijgedragen aan de objectlijst. Eenheden zijn in microseconden sinds 1 januari 19702.
    object_list JSON array   Een array die informatie bevat over alle gedetecteerde bewegende objecten in de scène2. Zie de velden hieronder voor de inhoud van elk object.
     OBJECT      
    id int   Een uniek nummer dat het object identificeert binnen de huidige draaiende instantie van de perceptiesoftware. Deze telling wordt gereset als de perceptie opnieuw wordt opgestart2.
    uuid std::string   Een unieke universele identificatie (UUID) voor objecten over alle draaiende instanties heen. Als de perceptie opnieuw opstart, zullen objecten in de nieuwe instantie unieke UUID's hebben ten opzichte van alle eerdere instanties3.
    classification std::string   De categorie van het object. Voor Ouster Detect 1.0 kunnen dit "PERSON", "TWO_WHEELER", "VEHICLE" of "LARGE_VEHICLE" zijn.
    classification_confidence double   Een getal tussen 0 en 1 dat het vertrouwen van het systeem in de toegewezen classificatie weergeeft (0 = geen vertrouwen, 1 = volledig vertrouwen)3.
    creation_ts int64_t µsec 1/1/70 Tijdstempel in microseconden sinds 1 januari 1970, toen het object voor het eerst zichtbaar was in het gezichtsveld van het systeem4.
    update_ts int64_t µsec 1/1/70 Tijdstempel in microseconden sinds 1 januari 1970, toen het object voor het laatst werd bijgewerkt4. Voor objecten die in het huidige frame zijn gemeten, is dit tijdstempel hetzelfde als het root-niveau tijdstempel4.
    Dimensions JSON container m  De lengte, breedte en hoogte van de bounding box die alle punten van het object omvat. Lengte is de uitbreiding langs de x-as, breedte langs de y-as, hoogte langs de z-as, waarbij de x-as wijst in de bewegingsrichting (rechterhandregel)5.
    frame_count int   Het aantal frames dat een object zichtbaar is geweest6.
    heading double Radians Positieve rotatie rond de z-as (rechterhandregel), gemeten vanaf de positieve x-as6.
    initial_position JSON container m De initiële XYZ-locatie van het object in het wereldreferentiekader, in het eerste frame dat het zichtbaar was6.
    num_points integer   Het aantal punten dat tot het object behoort7.
    orientation JSON container   Een quaternion die de oriëntatie van het object vertegenwoordigt ten opzichte van het wereldreferentiekader7.
    position JSON container m De huidige XYZ-locatie van het object in het wereldreferentiekader7.
    position_uncertainty JSON container m De geschatte variantie van de positiemeting. Eenheden zijn in meters²7.
    velocity JSON container m/s De huidige veranderingssnelheid in de XYZ-positie van het object in het wereldreferentiekader. Eenheden zijn in m/s8.
    velocity_uncertainty JSON container m/s De geschatte variantie van de snelheidsmeting. Eenheden zijn in (m/s)²8.

    Next steps

    • Check parsing Jesse's JSON files
    • Test FileMonitor
    • Add TOML directory for source
    • Finish SourceJSON
      • Derive from FileEventListener
      • Init starts file monitor
      • Stop quits file monitor
      • Time latency and add to frame
      • Test error handling
        • File not present
        • File locked
        • JSON structure damaged
    • Check error handling
      • Use try catch over returning bool
      • Error should appear on screen and in the logs
        • Check modification done to CTrack

    Solving JSON errors

    Sometimes getting an error, having a closer look at the JSON contents


    We see that there is no value in this case.

    Currently values are fetched with 

    void Object::FromJson(const json& j)
    {
      j.at("id").get_to(id);
      j.at("uuid").get_to(uuid);
      j.at("classification").get_to(classification);
      j.at("classification_confidence").get_to(classificationConfidence);
      j.at("creation_ts").get_to(creationTUsec);
      j.at("update_ts").get_to(updateTUsec);
      dimensions.from_json(j.at("Dimensions"));
      j.at("heading_rad").get_to(headingRad);
      headingVector.from_json(j.at("heading_vector"));
      initialPositionM.from_json(j.at("initial_position"));
      j.at("num_points").get_to(numPoints);
      orientation.from_json(j.at("orientation"));
      position_mm.from_json(j.at("position_mm"));
      position_llh_deg.from_json(j.at("position_llh_deg"));
      positionUncertaintyM.from_json(j.at("position_uncertainty"));
      velocityMs.from_json(j.at("velocity_mps"));
      velocityUncertaintyMs.from_json(j.at("velocity_uncertainty"));
    };

    .at will throw an exception if the value does not exist, that we can replace with .value



    in Daily blog
    # Xenomatix
    Porting 5GAlert to Jetson
    Droits d'auteur © CTech Solutions
    Nederlands (BE) | English (UK) | Français
    Généré par Odoo - Le #1 Open Source eCommerce