translate

This commit is contained in:
tankaitao 2026-08-04 16:30:42 +08:00
parent 08d58b2ccf
commit 459b76db1d
12 changed files with 193 additions and 2 deletions

View File

@ -91,6 +91,14 @@ enum class AgvTaskType {
Custom
};
/**
* @brief 使
*/
enum class AgvTranslationMode {
Odometry = 0,
Localization
};
/**
* @brief AGV
*
@ -102,6 +110,20 @@ struct AgvVelocity {
double wz{0.0};
};
/**
* @brief AGV
*/
struct AgvTranslation {
double distance{0.0};
double vx{0.0};
double vy{0.0};
AgvTranslationMode mode{AgvTranslationMode::Odometry};
};
/**
* @brief
*

View File

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

View File

@ -28,7 +28,7 @@ task_manager {
run_mode: TASK_RUN_MODE_BLOCKING_SERVICE
config_file: "tasks/quic_edge_task/quic_edge_task.pb.txt"
# Host-development default: no QUIC Gateway or physical media devices.
enable: true
enable: false
}
tasks {
id: "ume_teleop"

View File

@ -92,6 +92,21 @@ public:
return AgvResult::failure(AgvErrorCode::UnsupportedCommand, "followPath not implemented");
}
/**
* @brief
*
*
*/
virtual AgvResult translate(const AgvTranslation& translation)
{
(void)translation;
return AgvResult::failure(
AgvErrorCode::UnsupportedCommand,
"translate not implemented");
}
/**
* @brief /
*

View File

@ -51,6 +51,7 @@ public:
AgvResult followPath(
const std::vector<AgvPathSegment>& path,
const AgvMotionOptions& options) override;
AgvResult translate(const AgvTranslation& translation) override;
AgvResult pauseNavigation() override;
AgvResult resumeNavigation() override;
AgvResult cancelNavigation() override;

View File

@ -21,6 +21,7 @@ constexpr std::uint16_t kRobotTaskPause = 3001;
constexpr std::uint16_t kRobotTaskResume = 3002;
constexpr std::uint16_t kRobotTaskCancel = 3003;
constexpr std::uint16_t kRobotTaskGoTarget = 3051;
constexpr std::uint16_t kRobotTaskTranslate = 3055;
constexpr std::uint16_t kRobotTaskGoTargetList = 3066;
constexpr std::uint16_t kRobotTaskClearTargetList = 3067;
constexpr std::uint16_t kRobotConfigLock = 4005;

View File

@ -621,6 +621,68 @@ AgvResult SeerRobokitAgv::followPath(
options));
}
AgvResult SeerRobokitAgv::translate(
const AgvTranslation& translation)
{
if (!std::isfinite(translation.distance)
|| !std::isfinite(translation.vx)
|| !std::isfinite(translation.vy)) {
return AgvResult::failure(
AgvErrorCode::InvalidArgument,
"SEER Robokit translation distance, vx, and vy must be finite");
}
if (translation.distance <= 0.0) {
return AgvResult::failure(
AgvErrorCode::InvalidArgument,
"SEER Robokit translation distance must be greater than zero");
}
if (translation.vx == 0.0 && translation.vy == 0.0) {
return AgvResult::failure(
AgvErrorCode::InvalidArgument,
"SEER Robokit translation requires a non-zero vx or vy");
}
int mode = 0;
switch (translation.mode) {
case AgvTranslationMode::Odometry:
mode = 0;
break;
case AgvTranslationMode::Localization:
mode = 1;
break;
default:
return AgvResult::failure(
AgvErrorCode::InvalidArgument,
"SEER Robokit translation mode must be odometry or localization");
}
Json::Value payload(Json::objectValue);
jsonMember(payload, "dist") = translation.distance;
jsonMember(payload, "vx") = translation.vx;
jsonMember(payload, "vy") = translation.vy;
jsonMember(payload, "mode") = mode;
Json::Value response;
std::uint64_t accepted_generation = 0;
auto result = sendControlledCommand_(
sock_navigation_,
kRobotTaskTranslate,
payload,
&response,
&accepted_generation);
// API 3055 does not expose a task id. Do not publish a fake tracked task,
// but invalidate navigation state if the command may have been accepted.
if (accepted_generation != 0) {
clearPoseTask_(accepted_generation);
}
return result;
}
AgvResult SeerRobokitAgv::pauseNavigation()
{
Json::Value response;

View File

@ -72,6 +72,10 @@ public:
grpc::Status stopMapping(grpc::ServerContext* context,
const api::CommandHeader_Request* request,
api::CommandHeader_Feedback* response) override;
grpc::Status translate(
grpc::ServerContext* context,
const api::AgvTranslateCommand_Request* request,
api::AgvTranslateCommand_Feedback* response) override;
private:
device::DeviceManager& dmgr_;

View File

@ -121,6 +121,16 @@ device::AgvVelocity toVelocity(const msgs::AgvVelocity& src)
return {src.vx(), src.vy(), src.wz()};
}
device::AgvTranslation toTranslation(const msgs::AgvTranslation& src)
{
return {
src.distance(),
src.vx(),
src.vy(),
static_cast<device::AgvTranslationMode>(src.mode())
};
}
device::AgvPathSegment toPathSegment(const msgs::AgvPathSegment& src)
{
device::AgvPathSegment dst;
@ -501,6 +511,35 @@ grpc::Status gRPCAgvServiceImpl::followPath(grpc::ServerContext* context,
}
}
grpc::Status gRPCAgvServiceImpl::translate(
grpc::ServerContext* context,
const api::AgvTranslateCommand_Request* request,
api::AgvTranslateCommand_Feedback* response)
{
try {
if (context && context->IsCancelled()) {
return setNavigationRequestCanceled(response);
}
const std::string device_id = request->header().device_id();
auto agv = dmgr_.getDevice<device::AbstractAGV>(device_id);
if (!agv) {
return setDeviceNotFound(response, device_id);
}
return setResponseResult(
response,
agv->translate(toTranslation(request->translation())));
} catch (const std::exception& e) {
fillFeedback(response->mutable_header(), false, e.what());
return grpc::Status(
grpc::StatusCode::INTERNAL,
e.what());
}
}
grpc::Status gRPCAgvServiceImpl::pauseNavigation(grpc::ServerContext*,
const api::CommandHeader_Request* request,
api::CommandHeader_Feedback* response)

View File

@ -95,6 +95,23 @@ message AgvFollowPathCommand {
}
}
//
message AgvTranslateCommand {
message Request {
// header.device_id AGV
CommandHeader.Request header = 1;
//
cmvr.msgs.AgvTranslation translation = 2;
}
message Feedback {
//
CommandHeader.Feedback header = 1;
}
}
//
message AgvSetVelocityCommand {
//

View File

@ -69,4 +69,8 @@ service AgvService {
// /
rpc stopMapping(CommandHeader.Request) returns (CommandHeader.Feedback);
//
rpc translate(AgvTranslateCommand.Request) returns (AgvTranslateCommand.Feedback);
}

View File

@ -14,6 +14,29 @@ message AgvPose2d {
double theta = 3;
}
// 使
enum AgvTranslationMode {
//
AGV_TRANSLATION_MODE_ODOMETRY = 0;
//
AGV_TRANSLATION_MODE_LOCALIZATION = 1;
}
// AGV
message AgvTranslation {
// 0
double distance = 1;
// X /
double vx = 2;
// Y /
double vy = 3;
// 使
AgvTranslationMode mode = 4;
}
// AGV
message AgvVelocity {
// X 线/
@ -24,6 +47,9 @@ message AgvVelocity {
double wz = 3;
}
// AGV
message AgvBatteryState {
// [0, 1] 0.8 80%