Run the dock detector as an action, from raw scan to goal frame
This is the layer that turns the geometry into something the robot actually runs. It pulls a raw scan from the shared store, extracts lines, matches the dock pattern, transforms into the global frame and writes the result as a static transform - the same output contract FrameSampler has, so the charge sequence keeps working and nothing in move_base2, dock_planner or mission_adapters changes. Swapping detectors is one word in the YAML. It is also the only place in the chain allowed to know about TF, actions and the sensor store. The three packages beneath it stay free of all that, which is what lets their tests build a world, cast rays and finish in a millisecond with no runtime around them. Three things only break once the pieces are joined, and no core test can see them: The scan cursor. A 30 Hz control loop reading a 29 Hz lidar ticks more often than scans arrive. Without the cursor the same scan counts as several samples, min_samples stops meaning anything, and the handler commits on one measurement. TF arriving after the scan. The two come from different sources, so TF running a few milliseconds behind is routine. The store's cursor has already moved past that scan, so dropping the sample loses a detection outright every time TF is late. The detection is now held and transformed on a later tick, without re-running the match - the shape was already found, only the transform was missing. The regression test fails without that, which is how it earned its place. Transforming at the scan's own stamp rather than at the latest. The pose just computed belongs to the moment the scan was taken; looking up at another moment mixes two instants into one measurement. The error from "latest" is small but nobody knows how small, and a stamp on the wrong clock shows up exactly here. Rejections happen at boot, not at detection time: no sensor store, a scan_topic the store does not carry (listing the ones it does - a mistyped topic looks exactly like a dead sensor), no profiles, a pattern that is not implemented, a default_profile that does not exist. Every profile is validated, not just the default one, because a typo in the fifth profile that only surfaces at four in the afternoon is the worst kind. An order asking for a profile that does not exist fails and says which ones do. It does not quietly fall back to the default: using the wrong geometry means docking in the wrong place, not being slightly slower. The timeout message says which gate failed. Nothing matched, matched too rarely, or matched but never settled need opposite responses, and one failure line cannot carry that.
This commit is contained in:
461
test/dock_pattern_action_test.cpp
Normal file
461
test/dock_pattern_action_test.cpp
Normal file
@@ -0,0 +1,461 @@
|
||||
/*********************************************************************
|
||||
*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Kiểm handler dò dock từ LiDAR — chạy ĐÚNG chuỗi mà runtime chạy.
|
||||
*
|
||||
* Kho cảm biến thật + buffer tf3 thật + plugin nạp qua Boost.DLL. Chỉ scan là dựng sẵn: dựng hình
|
||||
* trước, chiếu tia sau, nên đáp án biết trước và sai lệch đo được bằng số.
|
||||
*
|
||||
* Trọng tâm là những chỗ chỉ HỎNG KHI GHÉP, mà test lõi không thấy: cursor scan, quy TF tại đúng
|
||||
* stamp, chọn profile từ actionParameters, và các đường từ chối lúc boot.
|
||||
*
|
||||
* Author: DuongTD
|
||||
*********************************************************************/
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <robot/node_handle.h>
|
||||
#include <tf3/buffer_core.h>
|
||||
|
||||
#include <action_core/action_registry.h>
|
||||
#include <robot_sensor_ports/sensor_store.h>
|
||||
#include <robot_sensor_ports/sensor_types.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
using action_core::ActionContext;
|
||||
using action_core::ActionHandler;
|
||||
using action_core::ActionRegistry;
|
||||
using action_core::ActionStatus;
|
||||
|
||||
constexpr const char* kGlobalFrame = "map";
|
||||
constexpr const char* kScanFrame = "front_laser";
|
||||
constexpr const char* kScanTopic = "/f_scan";
|
||||
constexpr const char* kOutFrame = "dock_target";
|
||||
constexpr double kInf = std::numeric_limits<double>::infinity();
|
||||
|
||||
/// @brief Quy giây thành tf3::Time QUA robot::Time.
|
||||
///
|
||||
/// Không tự tính `(t - sec) * 1e9`: phép đó cắt cụt và lệch một nano giây so với
|
||||
/// `robot::Time::fromSec`, đủ để lookup tại đúng stamp của scan báo "extrapolation into the
|
||||
/// future" và mẫu bị bỏ. Đi qua cùng một hàm đổi thì hai stamp khớp từng bit.
|
||||
tf3::Time toTf3Time(double t)
|
||||
{
|
||||
const robot::Time rt(t);
|
||||
return tf3::Time(rt.sec, rt.nsec);
|
||||
}
|
||||
|
||||
struct Segment
|
||||
{
|
||||
double ax, ay, bx, by; // [m]
|
||||
};
|
||||
|
||||
/// @brief Hai cánh của tấm chữ V. Góc TRONG tại đỉnh = pi - 2*half_angle.
|
||||
std::vector<Segment> vPlate(double apex_x, double half_angle, double wing)
|
||||
{
|
||||
const double tip_x = apex_x + wing * std::sin(half_angle);
|
||||
const double tip_y = wing * std::cos(half_angle);
|
||||
return { { apex_x, 0.0, tip_x, tip_y }, { apex_x, 0.0, tip_x, -tip_y } };
|
||||
}
|
||||
|
||||
robot_sensor_msgs::LaserScan makeScan(const std::vector<Segment>& world, double stamp_s,
|
||||
std::size_t rays = 600)
|
||||
{
|
||||
robot_sensor_msgs::LaserScan scan;
|
||||
scan.header.frame_id = kScanFrame;
|
||||
scan.header.stamp = robot::Time(stamp_s);
|
||||
scan.angle_min = -0.8f;
|
||||
scan.angle_max = 0.8f;
|
||||
scan.angle_increment = 1.6f / static_cast<float>(rays - 1);
|
||||
scan.range_min = 0.05f;
|
||||
scan.range_max = 20.0f;
|
||||
scan.ranges.assign(rays, static_cast<float>(kInf));
|
||||
|
||||
for (std::size_t i = 0; i < rays; ++i)
|
||||
{
|
||||
const double bearing = scan.angle_min + static_cast<double>(i) * scan.angle_increment;
|
||||
const double dx = std::cos(bearing);
|
||||
const double dy = std::sin(bearing);
|
||||
|
||||
for (const Segment& s : world)
|
||||
{
|
||||
const double ex = s.bx - s.ax;
|
||||
const double ey = s.by - s.ay;
|
||||
const double det = dx * (-ey) - dy * (-ex);
|
||||
if (std::fabs(det) < 1e-12)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const double t = (s.ax * (-ey) - s.ay * (-ex)) / det;
|
||||
const double u = (dx * s.ay - dy * s.ax) / det;
|
||||
if (t > 0.0 && u >= 0.0 && u <= 1.0 && t < scan.ranges[i])
|
||||
{
|
||||
scan.ranges[i] = static_cast<float>(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scan;
|
||||
}
|
||||
|
||||
robot_protocol_msgs::Action makeAction(const std::string& profile = std::string())
|
||||
{
|
||||
robot_protocol_msgs::Action action;
|
||||
action.actionType = "DetectCharger";
|
||||
action.actionId = "detect-1";
|
||||
if (!profile.empty())
|
||||
{
|
||||
robot_protocol_msgs::ActionParameter p;
|
||||
p.key = "dock_profile";
|
||||
p.value = profile;
|
||||
action.actionParameters.push_back(p);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
/// @brief Rig: kho thật + tf3 thật + plugin nạp qua đúng đường Boost.DLL.
|
||||
class Rig
|
||||
{
|
||||
public:
|
||||
explicit Rig(const std::string& ns = "actions_dock")
|
||||
{
|
||||
robot_sensor_ports::SensorStoreConfig store_config;
|
||||
robot_sensor_ports::SensorEntryConfig entry;
|
||||
entry.topic = kScanTopic;
|
||||
entry.data_type = "robot_sensor_msgs/LaserScan";
|
||||
entry.capacity = 1;
|
||||
entry.max_age = 0.5; // [s]
|
||||
store_config.sensors.push_back(entry);
|
||||
|
||||
std::string error;
|
||||
store_ok_ = store.configure(store_config, error);
|
||||
|
||||
// Cảm biến gắn tại gốc robot, robot tại gốc map — giữ phép biến đổi tầm thường để lệch nào ở
|
||||
// kết quả cũng là lệch của phép DÒ, không phải của phép quy đổi.
|
||||
setSensorPose(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
ctx.tf = &tf;
|
||||
ctx.sensors = &store;
|
||||
ctx.global_frame = kGlobalFrame;
|
||||
registry.setContext(ctx);
|
||||
loaded = registry.loadFromConfig(nh, ns);
|
||||
handler = registry.find("DetectCharger");
|
||||
}
|
||||
|
||||
void setSensorPose(double x, double y, double yaw, double stamp_s)
|
||||
{
|
||||
tf3::TransformStampedMsg t;
|
||||
t.header.stamp = toTf3Time(stamp_s);
|
||||
t.header.frame_id = kGlobalFrame;
|
||||
t.child_frame_id = kScanFrame;
|
||||
t.transform.translation.x = x;
|
||||
t.transform.translation.y = y;
|
||||
t.transform.translation.z = 0.0;
|
||||
t.transform.rotation.x = 0.0;
|
||||
t.transform.rotation.y = 0.0;
|
||||
t.transform.rotation.z = std::sin(yaw * 0.5);
|
||||
t.transform.rotation.w = std::cos(yaw * 0.5);
|
||||
tf.setTransform(t, "test", /*is_static=*/false);
|
||||
}
|
||||
|
||||
void push(const std::vector<Segment>& world, double stamp_s)
|
||||
{
|
||||
robot_sensor_ports::put(store, kScanTopic, makeScan(world, stamp_s), robot::Time(stamp_s));
|
||||
}
|
||||
|
||||
/// @brief Bơm @p count scan rồi tick, đúng nhịp mà control loop chạy.
|
||||
ActionStatus feed(const std::vector<Segment>& world, int count, double start_s = 10.0,
|
||||
double period = 0.1)
|
||||
{
|
||||
ActionStatus status = ActionStatus::kRunning;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
const double t = start_s + period * i;
|
||||
setSensorPose(0.0, 0.0, 0.0, t);
|
||||
push(world, t);
|
||||
const action_core::ActionTick tick = handler->update(robot::Time(t));
|
||||
status = tick.status;
|
||||
last_message = tick.message;
|
||||
++ticks;
|
||||
if (status != ActionStatus::kRunning)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
std::string last_message;
|
||||
int ticks = 0;
|
||||
bool store_ok_ = false;
|
||||
bool loaded = false;
|
||||
robot::NodeHandle nh;
|
||||
tf3::BufferCore tf;
|
||||
robot_sensor_ports::SensorStore store;
|
||||
ActionContext ctx;
|
||||
ActionRegistry registry;
|
||||
ActionHandler* handler = nullptr;
|
||||
};
|
||||
|
||||
// ================================================================================================
|
||||
// 1. Đường chạy đủ
|
||||
// ================================================================================================
|
||||
|
||||
TEST(DockPatternAction, DetectsAPlateAndWritesTheGoalFrame)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.store_ok_);
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
ASSERT_NE(rig.handler, nullptr);
|
||||
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
EXPECT_EQ(rig.feed(vPlate(1.20, M_PI / 4.0, 0.30), 8), ActionStatus::kSucceeded);
|
||||
|
||||
// Đỉnh ở x=1.20 trong frame cảm biến, cảm biến trùng gốc map, profile lùi 0.60 m ra phía robot.
|
||||
const tf3::TransformStampedMsg out = rig.tf.lookupTransform(kGlobalFrame, kOutFrame, tf3::Time());
|
||||
EXPECT_NEAR(out.transform.translation.x, 0.60, 0.05);
|
||||
EXPECT_NEAR(out.transform.translation.y, 0.00, 0.05);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, TheGoalFollowsTheSensorPose)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
|
||||
// Cảm biến dịch sang (2.0, 1.0) trong map. Kết quả phải ra theo — đây là chỗ phép quy TF sai sẽ
|
||||
// lộ, mà test lõi hình học không bao giờ thấy vì lõi làm việc trong frame của scan.
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
|
||||
ActionStatus status = ActionStatus::kRunning;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
const double t = 10.0 + 0.1 * i;
|
||||
rig.setSensorPose(2.0, 1.0, 0.0, t);
|
||||
rig.push(vPlate(1.20, M_PI / 4.0, 0.30), t);
|
||||
status = rig.handler->update(robot::Time(t)).status;
|
||||
if (status != ActionStatus::kRunning)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_EQ(status, ActionStatus::kSucceeded);
|
||||
|
||||
const tf3::TransformStampedMsg out = rig.tf.lookupTransform(kGlobalFrame, kOutFrame, tf3::Time());
|
||||
EXPECT_NEAR(out.transform.translation.x, 2.60, 0.05);
|
||||
EXPECT_NEAR(out.transform.translation.y, 1.00, 0.05);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, TheOrderPicksTheProfile)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
|
||||
// `v_wide` chờ tấm 120 độ và lùi 0.50 m. Order chọn nó qua actionParameters — đường đã verify:
|
||||
// chặng chỉ-action mang NGUYÊN actionParameters của action gốc.
|
||||
ASSERT_TRUE(rig.handler->start(makeAction("v_wide"), robot::Time(10.0)));
|
||||
ASSERT_EQ(rig.feed(vPlate(1.10, M_PI / 6.0, 0.25), 8), ActionStatus::kSucceeded);
|
||||
|
||||
const tf3::TransformStampedMsg out = rig.tf.lookupTransform(kGlobalFrame, kOutFrame, tf3::Time());
|
||||
EXPECT_NEAR(out.transform.translation.x, 0.60, 0.06);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, TheWrongProfileForTheShapeDoesNotDetect)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
|
||||
// Tấm 90 độ nhưng order xin profile 120 độ. Phải TRƯỢT, không được nhận bừa.
|
||||
ASSERT_TRUE(rig.handler->start(makeAction("v_wide"), robot::Time(10.0)));
|
||||
EXPECT_EQ(rig.feed(vPlate(1.20, M_PI / 4.0, 0.30), 12), ActionStatus::kRunning);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
// 2. Cursor scan — chỗ chỉ hỏng khi ghép
|
||||
// ================================================================================================
|
||||
|
||||
TEST(DockPatternAction, TickingWithoutANewScanCountsNothing)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
|
||||
rig.setSensorPose(0.0, 0.0, 0.0, 10.0);
|
||||
rig.push(vPlate(1.20, M_PI / 4.0, 0.30), 10.0);
|
||||
|
||||
// MỘT scan, nhưng tick nhiều lần — đúng như control loop 30 Hz đọc lidar 29 Hz. Không có cursor
|
||||
// thì cùng một scan bị đếm thành nhiều mẫu, `min_samples` mất hết ý nghĩa và handler chốt trên
|
||||
// một phép đo duy nhất.
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
ASSERT_EQ(rig.handler->update(robot::Time(10.0 + 0.01 * i)).status, ActionStatus::kRunning);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, EachNewScanCountsOnce)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
|
||||
// min_samples là 3, nên 2 scan chưa được chốt và 4 scan thì phải chốt.
|
||||
EXPECT_EQ(rig.feed(vPlate(1.20, M_PI / 4.0, 0.30), 2), ActionStatus::kRunning);
|
||||
EXPECT_EQ(rig.feed(vPlate(1.20, M_PI / 4.0, 0.30), 4, 10.2), ActionStatus::kSucceeded)
|
||||
<< "ticks=" << rig.ticks << " msg='" << rig.last_message << "'";
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
// 3. Đường hỏng
|
||||
// ================================================================================================
|
||||
|
||||
TEST(DockPatternAction, ADetectionSurvivesTfArrivingAfterTheScan)
|
||||
{
|
||||
// TF và scan tới từ hai nguồn khác nhau, nên TF chậm hơn scan vài mili giây là chuyện thường.
|
||||
// Cursor của kho đã nhảy qua scan đó rồi, nên bỏ mẫu ở đây là MẤT HẲN một phép dò mỗi lần TF trễ.
|
||||
// Phép dò phải được giữ lại và quy đổi ở tick sau.
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
|
||||
const std::vector<Segment> world = vPlate(1.20, M_PI / 4.0, 0.30);
|
||||
ActionStatus status = ActionStatus::kRunning;
|
||||
|
||||
for (int i = 0; i < 6 && status == ActionStatus::kRunning; ++i)
|
||||
{
|
||||
const double t = 10.0 + 0.1 * i;
|
||||
|
||||
// Scan tới TRƯỚC, TF chưa có ở stamp đó -> lookup phải trượt.
|
||||
rig.push(world, t);
|
||||
status = rig.handler->update(robot::Time(t)).status;
|
||||
if (status != ActionStatus::kRunning)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// TF đuổi kịp. Tick sau KHÔNG có scan mới, nhưng phép dò treo phải được giải quyết.
|
||||
rig.setSensorPose(0.0, 0.0, 0.0, t);
|
||||
status = rig.handler->update(robot::Time(t + 0.01)).status;
|
||||
}
|
||||
|
||||
EXPECT_EQ(status, ActionStatus::kSucceeded)
|
||||
<< "phép dò bị vứt khi TF trễ — mỗi lần TF chậm là mất một scan";
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, AnEmptySceneTimesOutAndSaysWhy)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
|
||||
rig.feed({}, 40, 10.0, 0.1);
|
||||
const action_core::ActionTick tick = rig.handler->update(robot::Time(16.0));
|
||||
|
||||
EXPECT_EQ(tick.status, ActionStatus::kFailed);
|
||||
// Thông điệp phải nói được HỎNG Ở CỔNG NÀO, không phải một dòng "detection failed".
|
||||
EXPECT_NE(tick.message.find("no 'v_std' pattern"), std::string::npos) << tick.message;
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, APalletCornerNeverBecomesADock)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
|
||||
// Góc pallet: ĐÚNG 90 độ, chỉ khác cạnh dài 0.8 m. Đây là dương tính giả điển hình trong kho.
|
||||
rig.feed(vPlate(1.20, M_PI / 4.0, 0.80), 40, 10.0, 0.1);
|
||||
const action_core::ActionTick tick = rig.handler->update(robot::Time(16.0));
|
||||
|
||||
EXPECT_EQ(tick.status, ActionStatus::kFailed);
|
||||
EXPECT_NE(tick.message.find("wing length"), std::string::npos) << tick.message;
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, ARunIsNotContaminatedByThePreviousOne)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(10.0)));
|
||||
ASSERT_EQ(rig.feed(vPlate(1.20, M_PI / 4.0, 0.30), 8), ActionStatus::kSucceeded);
|
||||
|
||||
// Lượt hai trên cảnh trống: nếu mẫu của lượt trước còn lại thì nó sẽ chốt ngay, tức dock vào chỗ
|
||||
// đã rời đi từ lâu.
|
||||
ASSERT_TRUE(rig.handler->start(makeAction(), robot::Time(20.0)));
|
||||
EXPECT_EQ(rig.feed({}, 8, 20.0), ActionStatus::kRunning);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
// 4. Từ chối LÚC BOOT
|
||||
// ================================================================================================
|
||||
|
||||
TEST(DockPatternAction, RefusesAScanTopicTheStoreDoesNotHave)
|
||||
{
|
||||
// Gõ sai tên topic là lỗi phổ biến nhất, và triệu chứng của nó GIỐNG HỆT cảm biến chết. Bắt lúc
|
||||
// boot, đừng để nó thành một lượt dò hết giờ.
|
||||
Rig rig("actions_dock_bad_topic");
|
||||
EXPECT_EQ(rig.handler, nullptr);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, RefusesAConfigWithNoProfile)
|
||||
{
|
||||
Rig rig("actions_dock_no_profile");
|
||||
EXPECT_EQ(rig.handler, nullptr);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, RefusesAPatternThatIsNotImplementedYet)
|
||||
{
|
||||
// Nhận nó nghĩa là dựng một bộ dò không bao giờ tìm thấy gì — nhìn giống hệt trạm ngoài tầm.
|
||||
Rig rig("actions_dock_unimplemented");
|
||||
EXPECT_EQ(rig.handler, nullptr);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, RefusesADefaultProfileThatDoesNotExist)
|
||||
{
|
||||
Rig rig("actions_dock_bad_default");
|
||||
EXPECT_EQ(rig.handler, nullptr);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, RefusesToStartOnAProfileTheOrderInvented)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
|
||||
// KHÔNG âm thầm rơi về default: dùng nhầm hình học là dock vào sai chỗ, không phải chậm hơn một
|
||||
// chút.
|
||||
EXPECT_FALSE(rig.handler->start(makeAction("khong_co_profile_nay"), robot::Time(10.0)));
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, RefusesToLoadWithoutASensorStore)
|
||||
{
|
||||
// Handler này đọc scan THÔ. Không có kho thì nó vô nghĩa, và phải nói ra lúc nạp.
|
||||
robot::NodeHandle nh;
|
||||
tf3::BufferCore tf;
|
||||
ActionContext ctx;
|
||||
ctx.tf = &tf;
|
||||
ctx.sensors = nullptr;
|
||||
ctx.global_frame = kGlobalFrame;
|
||||
|
||||
ActionRegistry registry;
|
||||
registry.setContext(ctx);
|
||||
registry.loadFromConfig(nh, "actions_dock");
|
||||
EXPECT_EQ(registry.find("DetectCharger"), nullptr);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#ifdef DOCK_PATTERN_ACTION_TEST_CONFIG_DIR
|
||||
setenv("PNKX_NAV_CORE_CONFIG_DIR", DOCK_PATTERN_ACTION_TEST_CONFIG_DIR, 0);
|
||||
#endif
|
||||
#ifdef DOCK_PATTERN_ACTION_TEST_LIBRARY_DIR
|
||||
setenv("PNKX_NAV_CORE_LIBRARY_PATH", DOCK_PATTERN_ACTION_TEST_LIBRARY_DIR, 0);
|
||||
#endif
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user