fix AGV live map streaming for SEER

This commit is contained in:
linbo 2026-10-09 10:37:44 +08:00
parent 9b2f5773e6
commit 55c978dbdd
6 changed files with 63 additions and 6 deletions

View File

@ -20,7 +20,7 @@ agv {
port_push: 19301
recv_timeout_ms: 1000
control_nick_name: "cmvr-es"
enable_state_push: true
enable_state_push: false
state_push_interval_ms: 200
state_push_included_fields: "x"
state_push_included_fields: "y"

View File

@ -147,7 +147,7 @@ device_manager {
id: "src1100"
type: DEVICE_TYPE_AGV
config_file: "devices/agv/agv.pb.txt"
enable: false
enable: true
}
devices {

View File

@ -5,7 +5,7 @@ task_manager {
run_mode: TASK_RUN_MODE_PERIODIC_STEP
control_period_s: 0.001
config_file: "tasks/touch_screen_task/touch_screen_task.pb.txt"
enable: true
enable: false
}
tasks {
id: "grpc_server"
@ -27,6 +27,6 @@ task_manager {
type: TASK_TYPE_QUIC_EDGE
run_mode: TASK_RUN_MODE_BLOCKING_SERVICE
config_file: "tasks/quic_edge_task/quic_edge_task.pb.txt"
enable: true
enable: false
}
}

View File

@ -1,6 +1,6 @@
grpc_server {
id: "grpc_server"
host: "0.0.0.0"
port: "50052"
port: "50053"
enable_reflection: true
}

View File

@ -33,7 +33,31 @@ static inline const Json::Value* jsonFind(
const Json::Value& value,
const char* key)
{
return value.find(key, key + std::strlen(key));
const auto* exact = value.find(key, key + std::strlen(key));
if (exact) {
return exact;
}
std::string lower_camel;
lower_camel.reserve(std::strlen(key));
bool uppercase_next = false;
for (const char* current = key; *current != '\0'; ++current) {
if (*current == '_') {
uppercase_next = true;
continue;
}
char character = *current;
if (uppercase_next && character >= 'a' && character <= 'z') {
character = static_cast<char>(character - 'a' + 'A');
}
lower_camel.push_back(character);
uppercase_next = false;
}
if (lower_camel == key) {
return nullptr;
}
return value.find(lower_camel.data(),
lower_camel.data() + lower_camel.size());
}
static inline Json::Value jsonGet(

View File

@ -715,6 +715,28 @@ AgvResult SeerRobokitAgv::parseSeerRobokitMap2D_(
}
}
const auto* occupied_points = jsonFind(root, "normal_pos_list");
if (occupied_points && occupied_points->isArray()
&& map.resolution > 0.0 && map.width > 0 && map.height > 0) {
const auto cell_count = static_cast<std::size_t>(map.width) * map.height;
map.data.assign(cell_count, 0);
for (const auto& point : *occupied_points) {
const auto grid_x = static_cast<int>(std::floor(
(jsonGet(point, "x", 0.0).asDouble() - map.origin.x)
/ map.resolution));
const auto grid_y = static_cast<int>(std::floor(
(jsonGet(point, "y", 0.0).asDouble() - map.origin.y)
/ map.resolution));
if (grid_x >= 0 && grid_y >= 0
&& grid_x < static_cast<int>(map.width)
&& grid_y < static_cast<int>(map.height)) {
const auto index = static_cast<std::size_t>(grid_y) * map.width
+ static_cast<std::size_t>(grid_x);
map.data[index] = 100;
}
}
}
const auto make_id = [](const Json::Value& value, const char* prefix, const int index) {
std::string id = jsonGet(value, "instance_name", "").asString();
if (id.empty()) id = jsonGet(value, "id", "").asString();
@ -861,6 +883,17 @@ AgvResult SeerRobokitAgv::parseSeerRobokitMap2D_(
if (map_id.empty()) map_id = jsonGet(header, "map_name", "").asString();
if (map_id.empty()) map_id = file_name;
if (map.resolution <= 0.0 || map.width == 0 || map.height == 0) {
return AgvResult::failure(
AgvErrorCode::CommandFailed,
"SEER Robokit 2D map has invalid resolution or bounds: " + file_name);
}
if (map.data.empty() && map.objects.empty()) {
return AgvResult::failure(
AgvErrorCode::CommandFailed,
"SEER Robokit 2D map has no renderable data: " + file_name);
}
update = {};
update.map_id = map_id;
update.dimension = AgvMapDimension::Map2D;