Files
robot_sensor_ports/package.xml
duongtd c60173d320 One place raw sensor readings live, shared by everything that needs them
Sensor data entered the navigation runtime and disappeared into the costmap.
At 0.05 m with inflation the costmap has destroyed ray order and object shape,
so a dock detector fitting lines to find a V plate cannot reconstruct what the
laser saw; two 0.2 m wings on that grid are one blob. A reinforcement-learning
local planner wants the raw scan for the same reason. Neither had a route to
it: ActionContext held only TF, and LocalPlanner::initialize takes only a
costmap.

The store keeps readings raw. Anything that wants filtering filters before
publishing here; the store does not know a filter exists. That split is
deliberate - a costmap wants outliers removed, a detector wants the true
shape, and a store deciding for both would be wrong for one of them.

Sharing is by shared_ptr to an immutable reading. Producers build a new one
and swap the pointer rather than writing in place, so a reader copies the
pointer under the mutex in tens of nanoseconds and then walks a thousand
ranges with nobody able to change them underneath. Two consumers reading one
topic share one copy rather than taking one each, which is what makes a
megabyte depth cloud affordable to share. A bare pointer into the store would
instead force every reader to hold the lock for the whole read, putting the
sensor input path behind however long a detector takes. The store keeps its
own mutex for the same reason: NavigationServer's already covers five kinds of
data, and readers running at control-loop rate do not belong in that queue.

Readers order on an arrival counter, not on the stamp. A stamp can go
backwards - host restart, a switch to simulated time, a replayed bag - and a
reader filtering on stamp then treats every later reading as old and freezes
for good, silently. The stamp is still kept, for TF lookups and for age, which
are different jobs. A consumer faster than its sensor gets null on the ticks
with nothing new rather than the same reading handed back to be counted twice.

The interface is type-erased because boost::dll-loaded plugins cross it. One
virtual per message type would mean a new virtual per sensor, reshuffling the
vtable and silently breaking every .so not rebuilt in the same pass - dlsym
plus reinterpret_cast catches none of that at compile time. So identity
travels as a string, payload as shared_ptr<const void>, and five virtuals
cover every message type that exists or will. The typed sugar is a header-only
template on the caller's side. typeid is avoided deliberately: comparing
type_index across a .so depends on visibility and on how the linker merges
typeinfo, and it fails quietly. Adding a message type is one line of a list
that generates both the trait and the YAML short-name table, so a type can
never be castable without being nameable, or the reverse.

A read with the wrong identity is refused and logged once, never cast.
static_pointer_cast to the wrong type reads garbage instead of crashing and
surfaces somewhere unrelated; that check is the only thing standing between
the erasure and it.

22 of the 24 robot_sensor_msgs types are registered. Imu and TimeReference are
not, because their headers do not compile here at all - Imu.h still carries
the unported ROS tail specialising ros::message_operations::Printer, and
TimeReference.h declares its field as ros::Time. Both are faults in
robot_sensor_msgs, and fixing them makes each one line here.

Config is refused at boot rather than at first use, and an undeclared topic is
dropped rather than added on the fly: an undeclared depth cloud would
otherwise cost megabytes a frame and the config would stop describing what the
process holds. A store with nothing declared stays silent - warning once per
topic about a feature nobody switched on is how a working system starts
printing errors after an upgrade.

SensorConsumer is the side channel for a local planner: widening
LocalPlanner::initialize would break every planner in the workspace at once
for the sake of the one that wants a scan, so a planner that wants sensor data
inherits this as well and the runtime finds out with a dynamic_cast.
2026-08-26 11:37:28 +07:00

50 lines
2.3 KiB
XML

<package>
<name>robot_sensor_ports</name>
<version>0.1.0</version>
<description>
Kho cảm biến dùng chung cho navigation runtime, cộng hai cổng hẹp nhìn vào nó.
Vấn đề gói này giải: dữ liệu cảm biến thô đi vào runtime rồi biến mất vào costmap. Bộ dò dock
cần đúng mảng `ranges` theo thứ tự tia — costmap đã inflate và xoá thứ tự đó nên không dựng lại
được. Consumer thứ hai (local planner học tăng cường) cũng cần bản thô. Kho này giữ một bản duy
nhất và chia cho mọi người.
Kho giữ bản THÔ. Muốn lọc thì lọc trước khi đẩy vào; kho không biết bộ lọc nào tồn tại. Costmap
và kho cố ý nhìn hai bản khác nhau khi bật lọc — costmap muốn bớt điểm nhiễu, bộ dò muốn hình
dạng thật.
Chia sẻ bằng `shared_ptr` tới bản BẤT BIẾN: producer dựng bản mới rồi tráo con trỏ, không sửa
tại chỗ. Reader giữ khoá đúng lúc copy con trỏ rồi đọc ngoài khoá. Hai consumer đọc cùng một
topic dùng chung một bản, không phải mỗi người một bản copy.
Interface xoá kiểu và không có template nào nằm trên ranh giới `.so`: thêm một loại message chỉ
tốn một dòng trong danh sách, không đổi interface và không bắt plugin nào build lại. Kiểu sai
thì bị từ chối kèm log, không bao giờ cast bừa.
Không chạy roscpp/ROS master; dùng lớp ROS-like robot_* (robot_cpp, robot_time,
robot_sensor_msgs).
</description>
<author>T800 Robotics</author>
<maintainer email="tdd@gmail.com">T800 Robotics</maintainer>
<license>BSD</license>
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>robot_cpp</build_depend>
<run_depend>robot_cpp</run_depend>
<build_depend>robot_time</build_depend>
<run_depend>robot_time</run_depend>
<!-- 24 loại message được đăng ký sẵn với kho. Xem sensor_types.h. -->
<build_depend>robot_sensor_msgs</build_depend>
<run_depend>robot_sensor_msgs</run_depend>
<build_depend>robot_xmlrpcpp</build_depend>
<run_depend>robot_xmlrpcpp</run_depend>
<build_depend>yaml-cpp</build_depend>
<run_depend>yaml-cpp</run_depend>
</package>