fix AGV live map streaming for SEER
This commit is contained in:
parent
9b2f5773e6
commit
55c978dbdd
@ -20,7 +20,7 @@ agv {
|
|||||||
port_push: 19301
|
port_push: 19301
|
||||||
recv_timeout_ms: 1000
|
recv_timeout_ms: 1000
|
||||||
control_nick_name: "cmvr-es"
|
control_nick_name: "cmvr-es"
|
||||||
enable_state_push: true
|
enable_state_push: false
|
||||||
state_push_interval_ms: 200
|
state_push_interval_ms: 200
|
||||||
state_push_included_fields: "x"
|
state_push_included_fields: "x"
|
||||||
state_push_included_fields: "y"
|
state_push_included_fields: "y"
|
||||||
|
|||||||
@ -147,7 +147,7 @@ device_manager {
|
|||||||
id: "src1100"
|
id: "src1100"
|
||||||
type: DEVICE_TYPE_AGV
|
type: DEVICE_TYPE_AGV
|
||||||
config_file: "devices/agv/agv.pb.txt"
|
config_file: "devices/agv/agv.pb.txt"
|
||||||
enable: false
|
enable: true
|
||||||
}
|
}
|
||||||
|
|
||||||
devices {
|
devices {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ task_manager {
|
|||||||
run_mode: TASK_RUN_MODE_PERIODIC_STEP
|
run_mode: TASK_RUN_MODE_PERIODIC_STEP
|
||||||
control_period_s: 0.001
|
control_period_s: 0.001
|
||||||
config_file: "tasks/touch_screen_task/touch_screen_task.pb.txt"
|
config_file: "tasks/touch_screen_task/touch_screen_task.pb.txt"
|
||||||
enable: true
|
enable: false
|
||||||
}
|
}
|
||||||
tasks {
|
tasks {
|
||||||
id: "grpc_server"
|
id: "grpc_server"
|
||||||
@ -27,6 +27,6 @@ task_manager {
|
|||||||
type: TASK_TYPE_QUIC_EDGE
|
type: TASK_TYPE_QUIC_EDGE
|
||||||
run_mode: TASK_RUN_MODE_BLOCKING_SERVICE
|
run_mode: TASK_RUN_MODE_BLOCKING_SERVICE
|
||||||
config_file: "tasks/quic_edge_task/quic_edge_task.pb.txt"
|
config_file: "tasks/quic_edge_task/quic_edge_task.pb.txt"
|
||||||
enable: true
|
enable: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
grpc_server {
|
grpc_server {
|
||||||
id: "grpc_server"
|
id: "grpc_server"
|
||||||
host: "0.0.0.0"
|
host: "0.0.0.0"
|
||||||
port: "50052"
|
port: "50053"
|
||||||
enable_reflection: true
|
enable_reflection: true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,31 @@ static inline const Json::Value* jsonFind(
|
|||||||
const Json::Value& value,
|
const Json::Value& value,
|
||||||
const char* key)
|
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(
|
static inline Json::Value jsonGet(
|
||||||
|
|||||||
@ -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) {
|
const auto make_id = [](const Json::Value& value, const char* prefix, const int index) {
|
||||||
std::string id = jsonGet(value, "instance_name", "").asString();
|
std::string id = jsonGet(value, "instance_name", "").asString();
|
||||||
if (id.empty()) id = jsonGet(value, "id", "").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 = jsonGet(header, "map_name", "").asString();
|
||||||
if (map_id.empty()) map_id = file_name;
|
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 = {};
|
||||||
update.map_id = map_id;
|
update.map_id = map_id;
|
||||||
update.dimension = AgvMapDimension::Map2D;
|
update.dimension = AgvMapDimension::Map2D;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user