From d5d3cf9edf0f4857e2e9c43e6396bd0828f999f5 Mon Sep 17 00:00:00 2001 From: Olli Koskelainen Date: Wed, 27 Mar 2024 13:28:43 +0200 Subject: [PATCH] Debug drawing extension to allow drawing primitives on HUD layer (#7168) * Extended debug draw functions to allow drawing primitives on HUD layer * Added documentation for new drawing features * Added debug draw changes to changelog --------- Co-authored-by: Olli --- CHANGELOG.md | 1 + Docs/python_api.md | 514 ++++++++++-------- LibCarla/source/carla/client/DebugHelper.cpp | 45 ++ LibCarla/source/carla/client/DebugHelper.h | 32 ++ LibCarla/source/carla/rpc/DebugShape.h | 28 +- PythonAPI/carla/source/libcarla/World.cpp | 30 + PythonAPI/docs/world.yml | 136 ++++- .../Carla/Source/Carla/Game/CarlaHUD.cpp | 27 +- .../Carla/Source/Carla/Game/CarlaHUD.h | 11 + .../Source/Carla/Util/DebugShapeDrawer.cpp | 209 ++++--- 10 files changed, 717 insertions(+), 316 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3971470bd79..0475512ba7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * make PythonAPI Windows: Fixed incompatibility issue with Anaconda due `py` command. * Added function to get actor' sockets names * Fixed bug in python agents when vehicle list was empty causing a check on all vehicles (BasicAgent.py) and detected pedestrians as vehicles if no pedestrains are present (BehaviourAgent.py) + * Extended debug drawing functions to allow drawing primitives on HUD layer * Added possibility to change gravity variable in imui sensor for the accelerometer * Fixed ROS2 native extension build error when ROS2 is installed in the system. * ROS2Native: Force fast-dds dependencies download to avoid build crash when boost_asio and tinyxml2 are not installed in Linux. diff --git a/Docs/python_api.md b/Docs/python_api.md index 617d8518ea5..88c0ae748de 100644 --- a/Docs/python_api.md +++ b/Docs/python_api.md @@ -722,13 +722,45 @@ Draws an arrow from `begin` to `end` pointing in that direction. - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. - **draw_box**(**self**, **box**, **rotation**, **thickness**=0.1, **color**=(255,0,0), **life_time**=-1.0) -Draws a box, ussually to act for object colliders. +Draws a box, usually to act for object colliders. - **Parameters:** - `box` (_[carla.BoundingBox](#carla.BoundingBox)_) - Object containing a location and the length of a box for every axis. - `rotation` (_[carla.Rotation](#carla.Rotation) - degrees (pitch,yaw,roll)_) - Orientation of the box according to Unreal Engine's axis system. - `thickness` (_float - meters_) - Density of the lines that define the box. - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. +- **draw_hud_arrow**(**self**, **begin**, **end**, **thickness**=0.1, **arrow_size**=0.1, **color**=(255,0,0), **life_time**=-1.0) +Draws an arrow on the HUD from `begin` to `end` which can only be seen server-side. + - **Parameters:** + - `begin` (_[carla.Location](#carla.Location) - meters_) - Point in the coordinate system where the arrow starts. + - `end` (_[carla.Location](#carla.Location) - meters_) - Point in the coordinate system where the arrow ends and points towards to. + - `thickness` (_float - meters_) - Density of the line. + - `arrow_size` (_float - meters_) - Size of the tip of the arrow. + - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. + - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. +- **draw_hud_box**(**self**, **box**, **rotation**, **thickness**=0.1, **color**=(255,0,0), **life_time**=-1.0) +Draws a box on the HUD, usually to act for object colliders. The box can only be seen server-side. + - **Parameters:** + - `box` (_[carla.BoundingBox](#carla.BoundingBox)_) - Object containing a location and the length of a box for every axis. + - `rotation` (_[carla.Rotation](#carla.Rotation) - degrees (pitch,yaw,roll)_) - Orientation of the box according to Unreal Engine's axis system. + - `thickness` (_float - meters_) - Density of the lines that define the box. + - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. + - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. +- **draw_hud_line**(**self**, **begin**, **end**, **thickness**=0.1, **color**=(255,0,0), **life_time**=-1.0) +Draws a line on the HUD in between `begin` and `end`. The line can only be seen server-side. + - **Parameters:** + - `begin` (_[carla.Location](#carla.Location) - meters_) - Point in the coordinate system where the line starts. + - `end` (_[carla.Location](#carla.Location) - meters_) - Spot in the coordinate system where the line ends. + - `thickness` (_float - meters_) - Density of the line. + - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. + - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. +- **draw_hud_point**(**self**, **location**, **size**=0.1, **color**=(255,0,0), **life_time**=-1.0) +Draws a point on the HUD at `location`. The point can only be seen server-side. + - **Parameters:** + - `location` (_[carla.Location](#carla.Location) - meters_) - Spot in the coordinate system to center the object. + - `size` (_float - meters_) - Density of the point. + - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. + - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. - **draw_line**(**self**, **begin**, **end**, **thickness**=0.1, **color**=(255,0,0), **life_time**=-1.0) Draws a line in between `begin` and `end`. - **Parameters:** @@ -4194,71 +4226,6 @@ document.getElementById("snipets-container").innerHTML = null; } -