Give action handlers a port onto the shared raw sensor store
A handler that samples through TF only ever sees what perception already decided. One that detects for itself - picking the V plate of a charging dock out of a laser scan - needs the ranges array in ray order, and the costmap at 0.05 m has inflated that away beyond reconstruction. ActionContext carried no way to reach sensor data at all, so that handler could not be written. It now carries a read-only port onto the store in robot_sensor_ports. Null when the host provides none, and a handler that needs sensor data is expected to refuse in configure() rather than discover it mid-shift, the same contract the tf pointer already has. The struct is crossed by boost::dll, so its layout is an ABI. Adding a field changes that layout and dlsym plus reinterpret_cast catches none of it at compile time - an old .so reads the old offsets off new data and returns garbage. The field goes at the end and the warning now says so in the doc, but the rule stands: every handler .so is rebuilt in the same pass.
This commit is contained in:
@@ -87,13 +87,14 @@ if(NOT BUILDING_WITH_CATKIN)
|
||||
/usr/local/lib
|
||||
)
|
||||
|
||||
# Gói này KHÔNG kéo costmap/tf3: action không chạm bản đồ và không phát vận tốc (D8), nên bốn
|
||||
# Gói này KHÔNG kéo costmap/tf3: action không chạm bản đồ và không phát vận tốc (D8), nên năm
|
||||
# thư viện dưới đây là toàn bộ phụ thuộc runtime của nó.
|
||||
set(STANDALONE_LIBRARIES
|
||||
robot_cpp
|
||||
robot_time
|
||||
robot_xmlrpcpp
|
||||
robot_protocol_msgs
|
||||
robot_sensor_ports
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -116,6 +117,7 @@ else()
|
||||
robot_time
|
||||
robot_protocol_msgs
|
||||
robot_xmlrpcpp
|
||||
robot_sensor_ports
|
||||
)
|
||||
|
||||
catkin_package(
|
||||
@@ -134,6 +136,7 @@ else()
|
||||
robot_time
|
||||
robot_protocol_msgs
|
||||
robot_xmlrpcpp
|
||||
robot_sensor_ports
|
||||
|
||||
DEPENDS
|
||||
Boost
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace tf3
|
||||
class BufferCore;
|
||||
}
|
||||
|
||||
namespace robot_sensor_ports
|
||||
{
|
||||
class SensorReader;
|
||||
}
|
||||
|
||||
namespace action_core
|
||||
{
|
||||
|
||||
@@ -34,6 +39,11 @@ namespace action_core
|
||||
*
|
||||
* @warning Con trỏ **non-owning**. Buffer thuộc navigation runtime và sống lâu hơn handler; handler
|
||||
* không được giữ bản sao nào của dữ liệu bên trong nó qua các tick.
|
||||
*
|
||||
* @warning Struct này đi qua ranh giới `boost::dll`. Thêm/bớt/đổi thứ tự trường là đổi layout, mà
|
||||
* `dlsym` + `reinterpret_cast` không bắt được lệch đó lúc biên dịch — handler cũ sẽ đọc
|
||||
* đúng offset cũ trên dữ liệu mới và ra rác. Mỗi lần sửa struct này phải build lại TOÀN BỘ
|
||||
* `.so` handler cùng một lượt, và trường mới luôn thêm vào CUỐI.
|
||||
*/
|
||||
struct ActionContext
|
||||
{
|
||||
@@ -45,6 +55,18 @@ struct ActionContext
|
||||
|
||||
/// Frame gắn với thân robot.
|
||||
std::string robot_base_frame = "base_link";
|
||||
|
||||
/**
|
||||
* Kho cảm biến thô dùng chung, chỉ-đọc. Có thể null — handler cần dữ liệu cảm biến phải tự từ
|
||||
* chối ở `configure()`.
|
||||
*
|
||||
* Vì sao cần dù đã có `tf`: handler dò mẫu qua TF chỉ thấy KẾT QUẢ của perception. Handler tự dò
|
||||
* (bắt chữ V của trạm sạc từ LiDAR chẳng hạn) cần mảng `ranges` theo đúng thứ tự tia — costmap ở
|
||||
* 0.05 m đã inflate và xoá mất thứ tự đó, không dựng lại được.
|
||||
*
|
||||
* Non-owning; kho thuộc navigation runtime và sống lâu hơn handler.
|
||||
*/
|
||||
const robot_sensor_ports::SensorReader* sensors = nullptr;
|
||||
};
|
||||
|
||||
} // namespace action_core
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
<build_depend>robot_xmlrpcpp</build_depend>
|
||||
<run_depend>robot_xmlrpcpp</run_depend>
|
||||
|
||||
<!-- Kho cảm biến thô dùng chung. Gói này chỉ dùng phần khai báo interface trong ActionContext;
|
||||
handler nào thật sự đọc cảm biến mới cần link. -->
|
||||
<build_depend>robot_sensor_ports</build_depend>
|
||||
<run_depend>robot_sensor_ports</run_depend>
|
||||
|
||||
<build_depend>yaml-cpp</build_depend>
|
||||
<run_depend>yaml-cpp</run_depend>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user