upload
This commit is contained in:
112
libs/vslam_common/include/vslam/robot_model.h
Normal file
112
libs/vslam_common/include/vslam/robot_model.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef VSLAM_ROBOT_MODEL_H
|
||||
#define VSLAM_ROBOT_MODEL_H
|
||||
|
||||
// Hinh hoc robot + cay frame, nap tu `robot.yaml`. THAY CHO URDF.
|
||||
//
|
||||
// ================== VI SAO LOP NAY TON TAI ==================
|
||||
// Truoc khi co no, phep dung `camera_depth_optical_frame -> base_link` bi
|
||||
// LAP LAI o bon file (hai tool va hai file test), moi cho mot ban chep cua
|
||||
// cung mot chuoi QuaternionMultiply. Va `cliff_detect.nominal_tz = 0.803` da
|
||||
// lech voi `sim.camera_z = 0.80` -- hai con so le ra phai la MOT.
|
||||
//
|
||||
// Do dung la lop bug "hai cho phai giu dong bo" ma `PROJECT_CONTEXT.md:71`
|
||||
// cua repo cu da ghi nhan giua URDF va launch param.
|
||||
//
|
||||
// Quy tac: KHONG stage nao duoc tu dung lai mot phep bien doi tu cac so trong
|
||||
// robot.yaml. Moi stage goi `RobotModel::StaticTransform()` hoac lay tu
|
||||
// `tree()`.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "vslam/config.h"
|
||||
#include "vslam/transform_tree.h"
|
||||
#include "vslam/vslam_common.h"
|
||||
|
||||
namespace vslam {
|
||||
|
||||
struct RobotGeometry {
|
||||
double wheel_radius = 0.075;
|
||||
double wheel_separation = 0.36;
|
||||
double robot_radius = 0.24;
|
||||
double body_half_width = 0.17;
|
||||
};
|
||||
|
||||
struct BaseLimits {
|
||||
double max_linear = 0.35;
|
||||
double max_angular = 0.80;
|
||||
double accel_limit = 0.30;
|
||||
double cmd_timeout = 0.30;
|
||||
};
|
||||
|
||||
struct WheelOdomNoise {
|
||||
double sigma_x_per_m = 0.02;
|
||||
double sigma_y_per_m = 0.02;
|
||||
double sigma_yaw_per_rad = 0.05;
|
||||
double slip_threshold = 0.20;
|
||||
bool slip_sigma_is_measured = true;
|
||||
};
|
||||
|
||||
class RobotModel {
|
||||
public:
|
||||
RobotModel();
|
||||
~RobotModel();
|
||||
|
||||
RobotModel(const RobotModel&) = delete;
|
||||
RobotModel& operator=(const RobotModel&) = delete;
|
||||
|
||||
// Nap tu node goc cua robot.yaml. Tra loi thay vi nem: nguoi goi quyet dinh
|
||||
// dung han hay chay voi mac dinh.
|
||||
//
|
||||
// Kiem, va TU CHOI neu sai:
|
||||
// - canh trung lap (hai dong cung `child`) -- cai sau se am tham thang;
|
||||
// - canh tao chu trinh;
|
||||
// - `child` mo coi (parent khong ton tai va khong phai base_link);
|
||||
// - khoa la trong `geometry:` / `base:` / `wheel_odom:` (go sai ten).
|
||||
StatusResponse Load(const ConfigNode& root);
|
||||
|
||||
// Nap tu duong dan file. Tien loi cho tool.
|
||||
StatusResponse LoadFile(const std::string& path);
|
||||
|
||||
const RobotGeometry& geometry() const { return geometry_; }
|
||||
const BaseLimits& base() const { return base_; }
|
||||
const WheelOdomNoise& wheel_odom() const { return wheel_odom_; }
|
||||
|
||||
// Cay frame, DA nap moi canh tinh. Ba canh dong (map->odom,
|
||||
// odom->base_footprint, base_footprint->base_link) do cac stage tuong ung
|
||||
// ghi vao, moi canh dung mot writer.
|
||||
TransformTree& tree() { return *tree_; }
|
||||
const TransformTree& tree() const { return *tree_; }
|
||||
|
||||
// Phep bien doi TINH giua hai frame. Chi di qua cac canh tinh, nen khong
|
||||
// can dau thoi gian va khong bao gio "chua co du lieu".
|
||||
//
|
||||
// Tra false neu mot trong hai frame khong ton tai hoac duong di di qua mot
|
||||
// canh dong -- truong hop do phai dung tree().Lookup() voi stamp.
|
||||
bool StaticTransform(const std::string& target, const std::string& source,
|
||||
Transform* out) const;
|
||||
|
||||
// Chieu cao camera so voi MAT SAN (khong phai so voi tam truc).
|
||||
//
|
||||
// Day chinh la `tz` ma cliff_detect mong doi, va la ly do
|
||||
// `cliff_detect.nominal_tz` KHONG duoc go tay: no la
|
||||
// camera_link.z + wheel_radius, tinh tu cung mot nguon.
|
||||
double camera_height_above_floor() const;
|
||||
|
||||
// Goc chuc xuong cua camera (rad), lay tu canh base_link -> camera_link.
|
||||
double camera_pitch() const;
|
||||
|
||||
private:
|
||||
RobotGeometry geometry_;
|
||||
BaseLimits base_;
|
||||
WheelOdomNoise wheel_odom_;
|
||||
std::unique_ptr<TransformTree> tree_;
|
||||
double camera_z_in_base_link_ = 0.0;
|
||||
double camera_pitch_ = 0.0;
|
||||
bool have_camera_ = false;
|
||||
};
|
||||
|
||||
} // namespace vslam
|
||||
|
||||
#endif // VSLAM_ROBOT_MODEL_H
|
||||
Reference in New Issue
Block a user