-
Notifications
You must be signed in to change notification settings - Fork 4
Added Debug drawings #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a477daa
87cf172
1c70fe0
d8acd4f
f8a56ff
d140e12
7ccdf93
933cfa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Tue Dec 9 14:28:38 2025 | ||
| WARNING: Nan, Inf or huge value in QACC at DOF 91. The simulation is unstable. Time = 80.6200. |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. qua cambierei i nomi delle funzioni e aggiungerei qualche commento perchè non si capisce bene la differenza tra i due tipi di debug drawing che puoi fare (quelle solo visive e quelle che partecipano alle collisioni). Magari puoi chiamarle drawVisualGeom e drawCollidingGeom o qualcosa di simile che comunque rende le cose più chiare
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dato che sono nomi forse è meglio cambiare idLocal in debugName o qualcosa di simile
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cambierei anche il nome della funzione per fare il check sull'esistenza della debug drawing
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non so se ti conviene creare una struct che ha i parametri standard che passi alla maggior parte delle funzioni. Facendo questo andrebbero rivisti parecchi nomi per non fare confusioni. Comunque per questo magari aspettiamo che qualcun altro risponda
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
a quali funzioni di riferisci? quelle nel private?
Andata per
che ne dici di isDebugDrawingExisting? Non so se hai suggerimenti
Non ho ben chiaro il motivo, le signature delle funzioni nel campo public mi sembrano sufficientemente chiare per uso esterno, per quelle nel private invece, la struct mi sembra inutile, anche perché sono due righe di codice
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
si, parlo di
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nella definizione dei tipi mjtGeom, c'è una divisione "regular geoms" e "rendering-only"; la differenza a livello di implementazione è che per usare le "rendering-only" bisogna chiamare anche
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ma le debug drawing devono essere un elemento puramente visivo, non possono avere collisioni ed interferire con la fisica. Tutto ciò che non è rendering-only va rimosso.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Screencast.from.10-12-2025.05.41.48.PM.webmHo cercato un pò su internet ed fatto un piccolo test. Attualmente le
Nell'ultimo commento di questa conversazione, spiega meglio queste cose: attualmente la struct N.B: ho fatto il print del campo Fatemi sapere cosa ne pensate, così committo i nuovi cambiamenti se vi ritrovato con quanto detto sopra |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| #pragma once | ||
|
|
||
| #include <mujoco/mujoco.h> | ||
|
|
||
| #include <QColor> | ||
| #include <algorithm> | ||
| #include <iostream> | ||
| #include <map> | ||
| #include <msgpack.hpp> | ||
|
|
||
| namespace spqr { | ||
| class DebugDrawings { | ||
| public: | ||
| static void init(mjvScene* s) noexcept; | ||
| static void drawDebugDrawings(); | ||
|
|
||
| static void processDebugMessage(std::map<std::string, msgpack::object>); | ||
| static void removeGeom(const std::string& idLocal); | ||
|
|
||
| // ---------------- regular geom types (mjtGeom) | ||
| /** | ||
| * @brief drawCircle: initialize a mjGEOM_CIRCLE in mujoco processing a predefined message from the socker | ||
| * with the framework | ||
| * @param idLocal: identifier of the debug drawing | ||
| * @param center: position of the center of the geom | ||
| * @param radius: radius of the circle | ||
| * @param color: RGBA color of the geom | ||
| */ | ||
| static void drawCircle(const std::map<std::string, msgpack::object>& data_map); | ||
|
|
||
| /** | ||
| * @brief drawSphere: initialize a mjGEOM_SPHERE in mujoco processing a predefined message from the socker | ||
| * with the framework | ||
| * @param idLocal: identifier of the debug drawing | ||
| * @param center: position of the center of the geom | ||
| * @param radius: radius of the sphere | ||
| * @param color: RGBA color of the geom | ||
| */ | ||
| static void drawSphere(const std::map<std::string, msgpack::object>& data_map); | ||
|
|
||
| /** | ||
| * @brief drawCylinder: initialize a mjGEOM_SPHERE in mujoco processing a predefined message from the | ||
| * socker with the framework | ||
| * @param idLocal: identifier of the debug drawing | ||
| * @param center: position of the center of the geom | ||
| * @param radius: radius of the cylinder | ||
| * @param length: half length of the cylinder | ||
| * @param color: RGBA color of the geom | ||
| */ | ||
| static void drawCylinder(const std::map<std::string, msgpack::object>& data_map); | ||
|
|
||
| // ---------------- rendering-only geom types (mjtGeom) | ||
|
|
||
| /** | ||
| * @brief drawArrow: initialize a mjGEOM_ARROW in mujoco processing a predefined message from the socker | ||
| * with the framework | ||
| * @param idLocal: identifier of the debug drawing | ||
| * @param start: position of the start point of the arrow | ||
| * @param end: position of the end point of the arrow | ||
| * @param thickness: thickness of the arrow | ||
| * @param color: RGBA color of the geom | ||
| */ | ||
| static void drawArrow(const std::map<std::string, msgpack::object>& data_map); | ||
|
|
||
| /** | ||
| * @brief drawLine: initialize a mjGEOM_LINE in mujoco processing a predefined message from the socker | ||
| * with the framework | ||
| * @param idLocal: identifier of the debug drawing | ||
| * @param start: position of the start point of the line | ||
| * @param end: position of the end point of the line | ||
| * @param thickness: thickness of the line | ||
| * @param color: RGBA color of the geom | ||
| */ | ||
| static void drawLine(const std::map<std::string, msgpack::object>& data_map); | ||
|
|
||
| private: | ||
| enum class drawGeomType { | ||
| Sphere, | ||
| Cylinder, | ||
| Circle, | ||
| Arrow, | ||
| Line, | ||
|
|
||
| COUNT, // keep this last | ||
| }; | ||
|
|
||
| static const char* toString(drawGeomType t) { | ||
| switch (t) { | ||
| case drawGeomType::Sphere: | ||
| return "Sphere"; | ||
| case drawGeomType::Cylinder: | ||
| return "Cylinder"; | ||
| case drawGeomType::Circle: | ||
| return "Circle"; | ||
| case drawGeomType::Arrow: | ||
| return "Arrow"; | ||
| case drawGeomType::Line: | ||
| return "Line"; | ||
| } | ||
| return "Unknown"; | ||
| } | ||
|
|
||
| constexpr bool isRegularGeom(drawGeomType t) { | ||
| switch (t) { | ||
| case drawGeomType::Sphere: | ||
| case drawGeomType::Cylinder: | ||
| case drawGeomType::Circle: | ||
| return true; | ||
| default: | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| struct GeomData { | ||
| mjvGeom geom; | ||
| drawGeomType customType; | ||
| }; | ||
|
|
||
| inline static mjvScene* ptrDebugDrawingsScene; // pointer to the mujoco scene where to draw the debug | ||
| // drawings | ||
| inline static std::map<mjString, GeomData> mapIdGeom; | ||
|
|
||
| /** | ||
| * @brief drawRegularGeom: draw a 'regular'-defined geometric primitive | ||
| * @param idLocal: identifier of the debug drawing | ||
| * @param mujocoType: standard MuJoCo geometric type (mjtGeom) | ||
| * @param customType: custom geometric type used to select the appropriate mjvGeom | ||
| * @param size: size of the geometric primitive | ||
| * @param pos: position of the geometric primitive | ||
| * @param color: color of the primitive (RGBA), can use QColorConstants. | ||
| */ | ||
| static void drawRegularGeom(mjString idLocal, mjtGeom mujocoType, drawGeomType customType, | ||
| const double size[3], const double pos[3], QColor color); | ||
|
|
||
| /** | ||
| * @brief drawRenderOnlyGeom: draw a 'rendering-only'-defined geometric primitive | ||
| * @param idLocal: identifier of the debug drawing | ||
| * @param mujocoType: standard MuJoCo geometric type (mjtGeom) | ||
| * @param customType: custom geometric type used to select the appropriate mjvGeom | ||
| * @param size: size of the geometric primitive | ||
| * @param start: start position of the geometric primitive | ||
| * @param end: end position of the geometric primitive | ||
| * @param width: width of the geometric primitive | ||
| * @param color: RGBA color of the geometric primitive, can be a QColorConstants | ||
| */ | ||
| static void drawRenderOnlyGeom(mjString idLocal, mjtGeom mujocoType, drawGeomType customType, | ||
| const double size[3], const double start[3], const double end[3], | ||
| const double width, QColor color); | ||
|
|
||
| /** | ||
| * @brief check is the mjv_Geom already exist. If true return the right mjvGeom into mjvScene->geoms | ||
| */ | ||
|
|
||
| static mjvGeom* isGeomExist(mjString idLocal, drawGeomType type); | ||
|
|
||
| /** | ||
| * @brief move the mjvGeom object | ||
| */ | ||
| static void moveGeom(mjvGeom* geom, const double center[3], QColor color); | ||
| static void moveGeom(mjvGeom* geom, const double start[3], const double end[3], QColor color); | ||
| }; | ||
|
|
||
| } // namespace spqr |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| image: ubuntu:22.04 | ||
| volumes: | ||
| - "/home/daniaffch/Dev/spqrbooster2026/src/SimBridge/bridge/build:/app/BridgeSubscriber" | ||
| - "/home/daniaffch/Dev/spqrbooster2026/src/SimBridge/fake_framework/build:/app/fake_framework" | ||
| - "/home/ubuntu/Robocup/spqrbooster2026/src/SimBridge/bridge/build:/app/BridgeSubscriber" | ||
| - "/home/ubuntu/Robocup/spqrbooster2026/src/SimBridge/fake_framework/build:/app/fake_framework" |
Uh oh!
There was an error while loading. Please reload this page.