feat: report camera depth capabilities and improve SEER AGV support

Add single-arm EtherCAT deployment configuration for device 234 using igc on enp1s0. Preserve configuration backup files outside the commit.
This commit is contained in:
xtkuang 2026-10-19 14:55:36 +08:00
parent b7e51afec4
commit dcf89b34d6
14 changed files with 384 additions and 25 deletions

View File

@ -0,0 +1,160 @@
arm {
robot_arms {
id: "right_ethercat_arm"
motor {
motor_system_id: "right_arm_ethercat_motors"
motor_group_ids: "right_arm_ethercat_motors"
dof: 7
joint_names: "right_arm_J1"
joint_names: "right_arm_J2"
joint_names: "right_arm_J3"
joint_names: "right_arm_J4"
joint_names: "right_arm_J5"
joint_names: "right_arm_J6"
joint_names: "right_arm_J7"
upd_freq: 1000
buffer_size: 50
default_vel: 1.0
default_acc: 2.0
}
kinematics {
pinocchio_dls_ik_solver {
urdf_path: "model/gen2/robot.urdf"
base_frame_name: "body_link"
flange_frame_name: "arm_link_7_2"
max_iters: 100
pos_eps: 1e-6
rot_eps: 1e-6
damping: 1e-6
joint_limit_policy {
limits {
enable: true
source: JOINT_LIMIT_SOURCE_CUSTOM
joints { joint_name: "right_arm_J1" q_lb: -3.14 q_ub: 3.14 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J2" q_lb: -1.64 q_ub: 1.64 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J3" q_lb: -3.14 q_ub: 3.14 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J4" q_lb: -1.60 q_ub: 1.60 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J5" q_lb: -3.14 q_ub: 3.14 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J6" q_lb: -0.37 q_ub: 0.79 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J7" q_lb: -0.61 q_ub: 0.58 qd: 5.0 qdd: 10.0 }
}
soft_limit {
enable: true
margin_ratio: 0.01
min_margin_rad: 0.01
}
avoidance {
enable: false
gain: 0.2
margin_ratio: 0.15
max_push: 0.25
}
}
}
}
motion {
move_j {
# MoveJ 轨迹完成后等待关节稳定的最长时间,单位为秒。
settle_timeout_s: 2.0
# MoveJ 完成时允许的最大关节位置误差,单位为弧度。
settle_position_tolerance_rad: 0.002
# MoveJ 完成时允许的最大关节速度,单位为弧度/秒。
settle_velocity_tolerance_rad_s: 0.02
# 位置和速度连续满足条件的采样次数。
settle_stable_sample_count: 3
toppra_joint_motion_planner {
path_type: TOPPRA_PATH_TYPE_QUINTIC
sample_period_s: 0.001
grid_size: 150
high_grid_size: 300
}
}
move_l {
pinocchio_cartesian_motion_planner {
sample_period_s: 0.001
position_gain: 4.0
rotation_gain: 4.0
line_deviation_check {
enable: true
line_deviation_warn_m: 0.01
line_deviation_stop_m: 0.03
line_direction_warn_deg: 20.0
line_direction_stop_deg: 45.0
line_direction_reset_deg: 10.0
line_check_min_distance_m: 0.01
}
joint_continuity_check {
enable: true
max_joint_delta_rad: 0.05
max_joint_velocity_rad_s: 10.0
max_joint_acceleration_rad_s2: 5000.0
}
cartesian_step_feasibility_check {
enable: true
min_linear_speed_ratio: 0.2
max_linear_direction_deviation_deg: 45.0
min_angular_speed_ratio: 0.2
max_angular_direction_deviation_deg: 45.0
min_desired_linear_speed: 1e-4
min_desired_angular_speed: 1e-4
}
}
}
speed_l {
pinocchio_cartesian_motion_planner {
linear_velocity_max: 0.55
linear_acceleration_max: 5.0
linear_jerk_max: 10.0
angular_velocity_max: 1.0
angular_acceleration_max: 5.0
angular_jerk_max: 12.0
linear_target_replan_threshold: 1e-4
angular_target_replan_threshold: 1e-4
linear_reverse_cos_threshold: -0.8660254037844386
linear_reverse_switch_speed_threshold: 1e-3
enforce_joint_acceleration_limits: true
line_deviation_check {
enable: true
line_deviation_warn_m: 0.01
line_deviation_stop_m: 0.03
line_direction_warn_deg: 20.0
line_direction_stop_deg: 45.0
line_direction_reset_deg: 10.0
line_check_min_distance_m: 0.01
}
joint_velocity_check {
enable: true
max_joint_velocity_rad_s: 30.0
max_joint_acceleration_rad_s2: 10000.0
}
cartesian_velocity_feasibility_check {
enable: true
min_linear_speed_ratio: 0.2
max_linear_direction_deviation_deg: 5.0
min_angular_speed_ratio: 0.2
max_angular_direction_deviation_deg: 5.0
min_desired_linear_speed: 1e-4
min_desired_angular_speed: 1e-4
}
}
speed_l_controller {
cartesian_velocity_controller {
control_period_s: 0.001
stop_twist_norm: 1e-9
stop_command_velocity_norm: 1e-3
stop_measured_velocity_norm: 1e-2
stop_acceleration: 10
# 等待 Cartesian 速度运动停止的最长时间,单位为秒。
stop_timeout_s: 2.0
}
}
}
}
}
}

View File

@ -0,0 +1,72 @@
motor {
id: "right_arm_ethercat_motors"
motor_groups {
id: "right_arm_ethercat_motors"
bus_type: MOTOR_BUS_ETHERCAT
vendor: MOTOR_VENDOR_EYOU
protocol: MOTOR_PROTOCOL_ETHERCAT_CIA402
ethercat {
master_index: 0
cycle_us: 1000
slave_op_timeout_ms: 12000
slave_state_poll_period_ms: 10
cia402 {
state_transition_timeout_ms: 1200
velocity_stop_timeout_ms: 2000
status_poll_period_ms: 10
stopped_velocity_tolerance_rad_s: 0.001
}
zero_calibration {
timeout_ms: 2000
poll_period_ms: 10
stable_sample_count: 5
position_tolerance_counts: 10000
stable_delta_counts: 1000
}
dc {
enable: false
reference_motor_id: 1
sync0_cycle_us: 1000
sync0_shift_us: 0
sync_reference_clock_period: 1
assign_activate: 768
sync_monitor_period_ms: 1000
}
slaves { motor_id: 1 alias: 0 position: 0 }
slaves { motor_id: 2 alias: 0 position: 1 }
slaves { motor_id: 3 alias: 0 position: 2 }
slaves { motor_id: 4 alias: 0 position: 3 }
slaves { motor_id: 5 alias: 0 position: 4 }
slaves { motor_id: 6 alias: 0 position: 5 }
slaves { motor_id: 7 alias: 0 position: 6 }
}
joint_limits {
enable: true
source: JOINT_LIMIT_SOURCE_CUSTOM
joints { joint_name: "right_arm_J1" q_lb: -3.14 q_ub: 3.14 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J2" q_lb: -1.64 q_ub: 1.64 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J3" q_lb: -3.14 q_ub: 3.14 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J4" q_lb: -1.60 q_ub: 1.60 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J5" q_lb: -3.14 q_ub: 3.14 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J6" q_lb: -0.37 q_ub: 0.79 qd: 5.0 qdd: 10.0 }
joints { joint_name: "right_arm_J7" q_lb: -0.61 q_ub: 0.58 qd: 5.0 qdd: 10.0 }
}
motors {
motors { id: 1 joint_name: "right_arm_J1" encoder_counts_per_rev: 65536 gear_ratio: 101.0 }
motors { id: 2 joint_name: "right_arm_J2" encoder_counts_per_rev: 65536 gear_ratio: 101.0 }
motors { id: 3 joint_name: "right_arm_J3" encoder_counts_per_rev: 65536 gear_ratio: 101.0 }
motors { id: 4 joint_name: "right_arm_J4" encoder_counts_per_rev: 65536 gear_ratio: 101.0 }
motors { id: 5 joint_name: "right_arm_J5" encoder_counts_per_rev: 65536 gear_ratio: 101.0 }
motors { id: 6 joint_name: "right_arm_J6" encoder_counts_per_rev: 65536 gear_ratio: 101.0 }
motors { id: 7 joint_name: "right_arm_J7" encoder_counts_per_rev: 65536 gear_ratio: 101.0 }
}
}
}

View File

@ -118,8 +118,8 @@ device_manager {
devices {
id: "right_arm_ethercat_motors"
type: DEVICE_TYPE_MOTOR_SYSTEM
config_file: "devices/motor/ethercat_motors.pb.txt"
enable: false
config_file: "devices/motor/ethercat_single_arm_motors.pb.txt"
enable: true
}
devices {
@ -210,13 +210,13 @@ device_manager {
id: "dual_arm_ethercat_motors"
type: DEVICE_TYPE_MOTOR_SYSTEM
config_file: "devices/motor/dual_arm_ethercat_motors.pb.txt"
enable: true
enable: false
}
devices {
id: "right_ethercat_arm"
type: DEVICE_TYPE_ROBOT_ARM
config_file: "devices/arm/ethercat_dual_arm.pb.txt"
config_file: "devices/arm/ethercat_single_arm.pb.txt"
enable: true
}
@ -224,7 +224,7 @@ device_manager {
id: "left_ethercat_arm"
type: DEVICE_TYPE_ROBOT_ARM
config_file: "devices/arm/ethercat_dual_arm.pb.txt"
enable: true
enable: false
}
}

View File

@ -31,6 +31,9 @@ constexpr std::uint16_t kRobotConfigUploadMap = 4010;
constexpr std::uint16_t kRobotConfigDownloadMap = 4011;
constexpr std::uint16_t kRobotOtherStartMapping = 6100;
constexpr std::uint16_t kRobotOtherStopMapping = 6101;
// The controller can emit this asynchronous mapping event on port 19210
// while a mapping session is active. It is not the reply to the next command.
constexpr std::uint16_t kRobotOtherMappingEventResponse = 17002;
constexpr std::uint16_t kRobotPushConfigReq = 9300;
constexpr std::uint16_t kRobotPushConfigRes = 19300;
constexpr std::uint16_t kRobotPush = 19301;

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;

View File

@ -133,25 +133,40 @@ AgvResult SeerRobokitAgv::sendCommandRaw_(
"SEER Robokit send command failed: " + systemError());
}
std::uint16_t response_command = 0;
std::string payload_text_response;
const auto result = receiveFrame_(sock, response_command, payload_text_response);
if (!result.ok()) {
return result;
}
const auto expected_response_command = static_cast<std::uint16_t>(
command + 10000U);
if (response_command != expected_response_command) {
return AgvResult::failure(
AgvErrorCode::CommandFailed,
"SEER Robokit response command mismatch: expected="
+ std::to_string(expected_response_command)
+ ", actual=" + std::to_string(response_command));
constexpr int kMaximumSkippedMappingEvents = 16;
for (int attempt = 0; attempt <= kMaximumSkippedMappingEvents; ++attempt) {
std::uint16_t response_command = 0;
std::string payload_text_response;
const auto result = receiveFrame_(
sock, response_command, payload_text_response);
if (!result.ok()) {
return result;
}
if (response_command == expected_response_command) {
if (response_payload) {
*response_payload = std::move(payload_text_response);
}
return AgvResult::success();
}
const bool is_mapping_event =
sock == sock_other_
&& response_command == kRobotOtherMappingEventResponse;
if (!is_mapping_event) {
return AgvResult::failure(
AgvErrorCode::CommandFailed,
"SEER Robokit response command mismatch: expected="
+ std::to_string(expected_response_command)
+ ", actual=" + std::to_string(response_command));
}
}
if (response_payload) {
*response_payload = std::move(payload_text_response);
}
return AgvResult::success();
return AgvResult::failure(
AgvErrorCode::Timeout,
"SEER Robokit timed out waiting for response command "
+ std::to_string(expected_response_command)
+ " after repeated asynchronous mapping events");
};
const auto close_matching_socket_locked = [this, sock]() {
if (sock == sock_status_) {

View File

@ -100,6 +100,8 @@ namespace cmvr::device {
// safely while another thread mutates it.
virtual void getState(CameraState &state) = 0;
virtual void getRGBImage(cv::Mat &color, Rs2Intrinsics& intrinsics) {}
virtual bool supportsDepthImage() const { return false; }
virtual bool supportsDepthStream() const { return false; }
virtual void getDepthImage(cv::Mat &depth, Rs2Intrinsics& intrinsics) {}
virtual void getRGBDImages(cv::Mat &color, cv::Mat &depth, Rs2Intrinsics& intrinsics) {}
virtual void startRecording(const std::string &video_path) {}

View File

@ -32,6 +32,8 @@ namespace cmvr::device
bool stop() override;
void getState(CameraState& state) override;
void getRGBImage(cv::Mat& color, Rs2Intrinsics& intrinsics) override;
bool supportsDepthImage() const override { return true; }
bool supportsDepthStream() const override { return false; }
void getDepthImage(cv::Mat& depth, Rs2Intrinsics& intrinsics) override;
void getRGBDImages(cv::Mat &color, cv::Mat &depth, Rs2Intrinsics& intrinsics) override;
void startRecording(const std::string &video_path) override;

View File

@ -49,6 +49,8 @@ public:
void setConsumeNewFrameOnly(bool enable);
void getRGBImage(cv::Mat& color, Rs2Intrinsics& intrinsics) override;
bool supportsDepthImage() const override { return true; }
bool supportsDepthStream() const override { return true; }
void getDepthImage(cv::Mat& depth, Rs2Intrinsics& intrinsics) override;
void getRGBDImages(cv::Mat& color, cv::Mat& depth, Rs2Intrinsics& intrinsics) override;
bool startStreaming() override;

View File

@ -26,6 +26,8 @@ namespace cmvr::device{
bool stop() override;
void getState(CameraState& state) override;
void getRGBImage(cv::Mat& color, Rs2Intrinsics& intrinsics) override;
bool supportsDepthImage() const override { return stream_mode_ != COLOR_MODE; }
bool supportsDepthStream() const override { return stream_mode_ != COLOR_MODE; }
void getDepthImage(cv::Mat& depth, Rs2Intrinsics& intrinsics) override;
void getRGBDImages(cv::Mat &color, cv::Mat &depth, Rs2Intrinsics& intrinsics) override;
void startRecording(const std::string &video_path) override;

View File

@ -133,6 +133,13 @@ grpc::Status gRPCCameraServiceImpl::GetStatus(grpc::ServerContext* context,
response->mutable_state()->set_width(state.width);
response->mutable_state()->set_height(state.height);
response->mutable_state()->set_codec(state.codec);
// Report driver capabilities without starting or capturing the camera.
auto* capabilities = response->mutable_state()->mutable_capabilities();
capabilities->set_version(1);
capabilities->set_driver(dev->typeName());
capabilities->set_depth_image(dev->supportsDepthImage());
capabilities->set_depth_stream(dev->supportsDepthStream());
return grpc::Status::OK;
}
catch(const exception &e) {
@ -261,6 +268,9 @@ grpc::Status gRPCCameraServiceImpl::GetDepthImage(grpc::ServerContext* context,
if (!dev) {
return failResponse(response, "Camera device not found: " + dev_id);
}
if (!dev->supportsDepthImage()) {
return failResponse(response, "Depth capture is not supported by camera: " + dev_id);
}
Rs2Intrinsics intrinsics = {0};
dev->getDepthImage(image,intrinsics);
if (image.empty()) {
@ -320,6 +330,9 @@ grpc::Status gRPCCameraServiceImpl::GetRGBDImages(grpc::ServerContext* context,
if (!dev) {
return failResponse(response, "Camera device not found: " + dev_id);
}
if (!dev->supportsDepthImage()) {
return failResponse(response, "Depth capture is not supported by camera: " + dev_id);
}
Rs2Intrinsics intrinsics = {0};
dev->getRGBDImages(color_image,depth_image, intrinsics);
if (color_image.empty()) {
@ -498,6 +511,12 @@ grpc::Status gRPCCameraServiceImpl::GetDepthImageStream(grpc::ServerContext* con
stream->Write(response);
return grpc::Status::OK;
}
if (!dev->supportsDepthStream()) {
api::GetDepthImageStreamCommand_Feedback response;
failResponse(&response, "Depth streaming is not supported by camera: " + dev_id);
stream->Write(response);
return grpc::Status::OK;
}
CameraStreamingLease stream_lease(dev);
if (!stream_lease) {
api::GetDepthImageStreamCommand_Feedback response;
@ -578,6 +597,12 @@ grpc::Status gRPCCameraServiceImpl::GetRGBDImagesStream(grpc::ServerContext* con
stream->Write(response);
return grpc::Status::OK;
}
if (!dev->supportsDepthStream()) {
api::GetRGBDImagesStreamCommand_Feedback response;
failResponse(&response, "Depth streaming is not supported by camera: " + dev_id);
stream->Write(response);
return grpc::Status::OK;
}
CameraStreamingLease stream_lease(dev);
if (!stream_lease) {
api::GetRGBDImagesStreamCommand_Feedback response;

View File

@ -1,3 +1,3 @@
MASTER0_DEVICE="4a:33:3f:30:c1:1b"
DEVICE_MODULES="generic"
UPDOWN_INTERFACES="enp2s0"
MASTER0_DEVICE="00:e0:4c:93:b1:b1"
DEVICE_MODULES="igc"
UPDOWN_INTERFACES="enp1s0"

View File

@ -38,6 +38,24 @@ message CameraIntrinsics {
repeated float coeffs = 5 [packed = true]; // 畸变系数(固定5个元素)
}
message CameraCapabilities {
uint32 version = 1;
string driver = 2;
string model = 3;
string serial = 4;
string transport = 5;
bool raw_image = 6;
bool valid_intrinsics = 7;
bool capture_timestamp = 8;
bool metric_aligned_depth = 9;
string distortion_model = 10;
uint64 session_generation = 11;
string unavailable_reason = 12;
string intrinsics_signature = 13;
bool depth_image = 14;
bool depth_stream = 15;
}
message CameraState {
bool is_initialized = 1;
bool is_opened = 2;
@ -49,6 +67,7 @@ message CameraState {
int32 width = 8;
int32 height = 9;
string codec = 10;
CameraCapabilities capabilities = 11;
}
message GetCameraStateCommand {