Commit Graph

84 Commits

Author SHA1 Message Date
7c6d070bd5 feat(static_layer): report current only after the map reaches the master
current_ is false before the first map, after every new map, update or
resize, and becomes true only once updateCosts has written the map
(shared markMapWritten helper, also called by CriticalLayer). Readiness
flags are written under the master mutex so the planner can trust
isCurrent() taken under the same lock. Invalid partial updates are
rejected with a throttled error.
2026-11-04 11:14:15 +07:00
52089a0e90 feat(directional_layer): make the allowed deviation configurable
Add max_deviation_deg (default 90, valid 0 < x < 180). The field carries
the value so checkSegment and every planner use the same rule. 90 keeps
the previous masks bit for bit; out-of-range values stop the layer from
initialising.
2026-11-04 08:52:00 +07:00
5e7a22cad8 fix(static_layer): ignore grids addressed to another layer's topic
The sensor gateway sends every OccupancyGrid to every layer of the matching type, so a StaticLayer also sees the direction grid and other StaticLayers' maps. Those used to log two unthrottled errors per push. Right type on another topic is normal traffic and is now ignored; only an unknown data type still logs an error.
2026-11-03 16:57:01 +07:00
3d552b49d0 feat(directional_layer): rewrite as a direction field provider
DirectionalLayer no longer derives from StaticLayer and never writes the
master grid. It receives an OccupancyGrid of direction codes (0 = no
constraint, 1..8 = direction_index + 1) on direction_topic, validates it
against the master geometry and global frame, and publishes an immutable
DirectionField snapshot with a DISABLED / PENDING / READY state and a
generation counter. Every static map on map_topic drops the snapshot and
returns the layer to PENDING until a grid for that map arrives.

direction_field.h holds the core API used by planners: grid validation,
DirectionField with bounds-checked codeAt(), a half-open-cell DDA
(traverseGridSegment), allowedDirectionMask() and checkSegment().
LayeredCostmap::getDirectionFieldSnapshot() exposes the snapshot through
the DirectionFieldProvider interface without adding data members.

Tests: direction_field_test (7) and directional_layer_test (5) pass.
2026-11-03 16:55:10 +07:00
3539afbfb4 build(test): link yaml-cpp into depth_camera_obstacle_layer_test
The test calls yaml-cpp directly; without it the link fails with "DSO missing from command line" when BUILD_COSTMAP_TESTS is ON.
2026-10-28 13:43:56 +07:00
757b381659 feat(depth_layer): add occlusion_guard and attach_distance
occlusion_guard (default false): keep a stored point when a nearer object blocks the ray to it, clear a point the camera sees through. attach_distance (default 0.12 m, as before) is now read per source. Both keys are forwarded from the parent costmap parameters. README, params YAML and tests updated.
2026-10-27 13:09:31 +07:00
9b93a45b45 refactor(depth_layer): read parameters like the other layers
DepthCameraObstacleLayer::loadParameters() wrapped each key in a
readParam() helper. It now reads the same way as
ObstacleLayer::getParams(): one block of loadParam() calls on the default
file, then one block of "if (priv_nh.hasParam(k)) priv_nh.getParam(k, v)"
on "<costmap>/<plugin>". The per-source keys do the same on
"<costmap>/<plugin>/<source>". Values and precedence are unchanged.

getParam() gets the current value as its default, so a value of the
wrong type keeps the file default instead of becoming 0, false or "".
The layer no longer throws on a wrong type itself. A wrong type in the
shared block still stops the costmap, in copyParentParameters(). The two
wrong-type test cases, which set the layer namespace directly, are
removed.
2026-10-22 10:56:10 +07:00
e40e9c0104 fix(costmap): one parameter flow for every layer; fail on a bad layer
Each layer reads its default file under $PNKX_NAV_CORE_CONFIG_DIR/config,
then overrides a key from "<costmap>/<plugin>".
Costmap2DROBOT::copyParentParameters() copies the shared "<plugin>:"
block there first. This was broken in three ways:
- the copy lists covered only part of what the layers read, so a key set
  in the shared block was dropped without a word;
- DepthCameraObstacleLayer had no default file and read the shared block
  itself;
- a layer that failed to initialize left a half-built costmap that
  reported READY.

Failing loudly:
- costmap_2d_robot.cpp: a failing layer, a malformed plugins: list or a
  missing costmap_params.yaml throws std::runtime_error with the costmap
  and layer name, after releasing layered_costmap_.
  NavigationRuntime::buildCostmaps() turns this into an initialization
  error, so the host never reports READY.
- Static/Obstacle/Voxel/Inflation and DepthCameraObstacleLayer throw when
  their default file cannot be opened.
- A key whose value does not convert to the type the layer reads throws.
  getParam() used to write 0, false or "" into the value, and that was
  copied as if configured.

One flow:
- copyParentParameters() copies every key each layer reads, with the
  layer's type, including a new DepthCameraObstacleLayer branch. Copies no
  layer reads are dropped.
- DepthCameraObstacleLayer::loadParameters() reads
  config/depth_camera_obstacle_layer_params.yaml (new, equal to the C++
  defaults), then "<costmap>/<plugin>". ParamReader is gone, and so is the
  node_handle.cpp:265 warning at start-up.
- VoxelLayer: z_resolution can be overridden; unknown_threshold is
  computed after the final z_voxels; the column keys are range-checked;
  the effective column is logged once at start-up.
- config/obstacle_layer_params.yaml: drop the per-source keys the layer
  never read there.
- depth_camera_obstacle_layer_test: set PNKX_NAV_CORE_CONFIG_DIR; add
  tests for a wrong type and a missing default file.

Squash of fix/config-flow (ae7fce9, f8705e1). Checked on the KIT robot on
22/10/2026:
- the depth layer summary at start-up is unchanged;
- a shared-block key now reaches VoxelLayer;
- FOV_W 3.5, z_voxels 17, a wrong-typed key and a missing default file
  each give INITIALIZATION_FAILED.
2026-10-22 10:49:31 +07:00
3b89add5ee refactor(obstacle_layer): drop the DepthCameraData startup guard
ObstacleLayer and VoxelLayer no longer carry any depth code, so the check
that rejected a DepthCameraData source or frustum_clearing_enabled goes too.
A DepthCameraData source still fails at startup through the generic
data_type check; frustum_clearing_enabled is now an unknown key.

The README and the LayerType comment now say the gateway feeds
DepthCameraObstacleLayer PointCloud2 only.
2026-10-21 14:10:55 +07:00
64974d48b7 feat(depth): DepthCameraObstacleLayer replaces depth clearing in ObstacleLayer/VoxelLayer
Depth cameras now go through their own costmap layer instead of the
frustum clearing that lived in ObstacleLayer and VoxelLayer.

- Add DepthCameraObstacleLayer. It stores marked points per costmap
  column, clears stored points inside each camera frustum with a kd-tree
  check against the new cloud, keeps points outside the view, groups
  points with Euclidean clustering, and does not mark a 12 cm band at the
  frustum faces.
- The layer follows the CostmapLayer contract: updateWithMax/Overwrite by
  combination_method, reset(), clearArea() with the usual invert
  semantics, footprint clearing, matchSize() and the layer mutex. So
  ClearCostmapRecovery and costmap resets work on it.
- Add LayerType::DEPTH_CAMERA_LAYER, appended last so the existing values
  keep their numbers. The host's SensorGateway must dispatch PointCloud2
  and DepthCameraData to it (move_base2 feature/depth-camera-layer-type).
- Remove the frustum clearing code from Observation, ObservationBuffer,
  ObstacleLayer, VoxelLayer and costmap_2d_robot.cpp.
- ObstacleLayer and VoxelLayer now reject a DepthCameraData source or
  frustum_clearing_enabled: true at startup, with a message that points
  to DepthCameraObstacleLayer.
- Link PCL into the plugins library only. Add 21 unit tests for the layer
  (depth_camera_obstacle_layer_test).

Squashed from feature/depth-observed-volume (2ca0bcc..40dc70e).
2026-10-21 13:16:07 +07:00
a63c084002 Bring main up to the dev_cam_intel line
main had not moved since 11 July, while the depth-camera work continued on
dev_cam_intel for six weeks. The two branches did not diverge by accident: they
ended up holding two different clearing designs for the same layer.

main carried frustum clearing as VoxelLayer members - frustum_clearing_enabled_,
a pixel step and a min/max range - driven from costmap_2d_robot. dev_cam_intel
replaced that with a full-column clearing pass whose configuration lives per
observation, so the layer keeps no frustum state of its own.

This commit takes the dev_cam_intel tree whole. It is the line running on the
robot, the one rb_ws points at, and the one the NUC measurements were taken
against; the frustum design is superseded rather than merged, and stays in
history at 45c8227 if it is ever wanted back.

Squashed deliberately: the nineteen commits behind it are a working diary -
metrics that were added and removed, test toggles, an optimal-run series - and
none of that is worth carrying onto a branch other trees track.
2026-08-27 13:41:42 +07:00
45c8227f5c change topic and msg depth camera 2026-07-11 10:09:55 +07:00
faa57d9c93 change topic and msg depth camera 2026-07-11 09:50:40 +07:00
a2a021c114 add function computeCost file layer.h 2026-07-10 11:27:20 +07:00
2fcd211ccf update 2026-03-03 07:26:47 +00:00
3d621de809 fix bugs 2026-02-26 14:54:23 +07:00
1f9e9f1398 update 2026-02-26 14:52:33 +07:00
9208c8bcdc WIP: fix costmap_2d_robot 2026-02-26 14:49:45 +07:00
6c6e5b44f8 update copyParentParameters 2026-02-26 14:43:17 +07:00
eb52edc6e8 update tf3 2026-02-07 11:00:46 +07:00
ed43912c33 delete console_brigde 2026-02-06 10:14:35 +00:00
9026c03e1e update 2026-01-13 14:30:13 +07:00
81e7874274 Duong update 2026-01-12 15:48:43 +07:00
9d3d31a4f9 include <robot/console.h> 2026-01-10 14:10:41 +07:00
b18aeb39ab replaced printf -> robot::console 2026-01-10 11:38:19 +07:00
b66bd7c751 DuongTD gui zalo 2026-01-10 10:16:51 +07:00
384897b750 update from DuongTD 2026-01-08 10:35:27 +07:00
f052dac142 update for ROS 2026-01-07 16:55:01 +07:00
80bde38f4d ros 2026-01-07 09:26:36 +07:00
03c151afd2 update 2026-01-06 17:49:14 +07:00
a8fc8cb9a4 Merge branch 'main' of https://git.pnkr.asia/DuongTD/costmap_2d into main 2026-01-06 17:37:52 +07:00
800e5c1735 update obstacle_layer 2026-01-06 17:33:13 +07:00
b6733ae04c update 2025-12-31 15:43:07 +07:00
ae469e3271 add function getTypeLayer 2025-12-31 10:11:12 +07:00
6c682712fe hiep update 2025-12-30 10:42:34 +07:00
72b2f3c639 Hiep update 2025-12-30 10:24:18 +07:00
4246453ae6 hiep sua ten file 2025-12-30 09:56:35 +07:00
2c3d7d586d HiepLM update 2025-12-30 09:08:14 +07:00
71adf1390f hiep sua 2025-12-29 18:01:03 +07:00
59b0b1a806 update 2025-12-29 17:43:03 +07:00
ed54b7b8db Hiep sua file 2025-12-29 17:42:32 +07:00
a28f05c6d5 update 2025-12-29 10:22:16 +07:00
0344c31e5b update 2025-12-25 11:06:15 +07:00
10521c1629 update 2025-12-24 17:16:05 +07:00
b3be5da393 Merge branch 'main' of https://git.pnkr.asia/DuongTD/costmap_2d into main 2025-12-24 14:21:57 +07:00
b807d2c187 Merge branch 'main' of https://git.pnkr.asia/DuongTD/costmap_2d into main 2025-12-24 14:21:14 +07:00
674fb07ad3 update 2025-12-24 14:19:29 +07:00
2bcd8e606b update 2025-12-19 15:35:37 +07:00
fdfba18bde update 2025-12-16 15:13:07 +07:00
e80eddc2c2 update load param using node handle 2025-12-11 17:27:50 +07:00