mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-11-09 17:04:38 -06:00
change Vector3 to tensor moudle
This commit is contained in:
@@ -273,17 +273,17 @@ namespace maix::ahrs
|
||||
/**
|
||||
* Get angle by mahony complementary filter, will automatically call update method,
|
||||
* and automatically call init in first time.
|
||||
* @param acc accelerometer data, unit is g or raw data. maix.Vector3f type.
|
||||
* @param gyro gyroscope data, unit can be rad/s or degree/s, if rad/s, arg radian should be true. maix.Vector3f type.
|
||||
* @param mag magnetometer data, optional, if no magnetometer, set all value to 0. maix.Vector3f type.
|
||||
* @param acc accelerometer data, unit is g or raw data. maix.vector.Vector3f type.
|
||||
* @param gyro gyroscope data, unit can be rad/s or degree/s, if rad/s, arg radian should be true. maix.vector.Vector3f type.
|
||||
* @param mag magnetometer data, optional, if no magnetometer, set all value to 0. maix.vector.Vector3f type.
|
||||
* @param dt delta T of two time call get_anle, unit is second, float type.
|
||||
* @param radian if gyro's unit is rad/s, set this arg to true, degree/s set to false.
|
||||
* @return rotation angle data, maix.Vector3f type.
|
||||
* @return rotation angle data, maix.vector.Vector3f type.
|
||||
* @maixpy maix.ahrs.MahonyAHRS.get_angle
|
||||
*/
|
||||
Vector3f get_angle(Vector3f acc, Vector3f gyro,Vector3f mag, float dt, bool radian = false)
|
||||
tensor::Vector3f get_angle(tensor::Vector3f acc, tensor::Vector3f gyro, tensor::Vector3f mag, float dt, bool radian = false)
|
||||
{
|
||||
Vector3f angle;
|
||||
tensor::Vector3f angle;
|
||||
|
||||
update(acc.x, acc.y, acc.z, gyro.x, gyro.y, gyro.z, mag.x, mag.y, mag.z, dt);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "math.h"
|
||||
|
||||
namespace maix
|
||||
namespace maix::tensor
|
||||
{
|
||||
template <typename T>
|
||||
class Vector3
|
||||
@@ -63,21 +63,21 @@ namespace maix
|
||||
|
||||
/**
|
||||
* Vector3 float type.
|
||||
* @maixpy maix.Vector3f
|
||||
* @maixpy maix.tensor.Vector3f
|
||||
*/
|
||||
class Vector3f : public Vector3<float> // we use class for we want to generate maixpy API, and the tool not suppoort using yet.
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
* @maixcdk maix.Vector3f.Vector3f
|
||||
* @maixcdk maix.tensor.Vector3f.Vector3f
|
||||
*/
|
||||
Vector3f() : Vector3<float>() {}
|
||||
|
||||
/**
|
||||
* Construct Vector3f with 3 variables.
|
||||
* @maixpy maix.Vector3f.__init__
|
||||
* @maixcdk maix.Vector3f.Vector3f
|
||||
* @maixpy maix.tensor.Vector3f.__init__
|
||||
* @maixcdk maix.tensor.Vector3f.Vector3f
|
||||
*/
|
||||
Vector3f(float x0, float y0, float z0)
|
||||
: Vector3<float>(x0, y0, z0)
|
||||
@@ -85,40 +85,40 @@ namespace maix
|
||||
|
||||
/**
|
||||
* member x.
|
||||
* @maixpy maix.Vector3f.x
|
||||
* @maixpy maix.tensor.Vector3f.x
|
||||
*/
|
||||
// float x;
|
||||
|
||||
/**
|
||||
* member y.
|
||||
* @maixpy maix.Vector3f.y
|
||||
* @maixpy maix.tensor.Vector3f.y
|
||||
*/
|
||||
// float y;
|
||||
|
||||
/**
|
||||
* member z.
|
||||
* @maixpy maix.Vector3f.z
|
||||
* @maixpy maix.tensor.Vector3f.z
|
||||
*/
|
||||
// float z;
|
||||
};
|
||||
|
||||
/**
|
||||
* Vector3 int32_t type.
|
||||
* @maixpy maix.Vector3i32
|
||||
* @maixpy maix.tensor.Vector3i32
|
||||
*/
|
||||
class Vector3i32 : public Vector3<int32_t> // we use class for we want to generate maixpy API, and the tool not suppoort using yet.
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
* @maixcdk maix.Vector3i32.Vector3i32
|
||||
* @maixcdk maix.tensor.Vector3i32.Vector3i32
|
||||
*/
|
||||
Vector3i32() : Vector3<int32_t>() {}
|
||||
|
||||
/**
|
||||
* Construct Vector3i32 with 3 variables.
|
||||
* @maixpy maix.Vector3i32.__init__
|
||||
* @maixcdk maix.Vector3i32.Vector3i32
|
||||
* @maixpy maix.tensor.Vector3i32.__init__
|
||||
* @maixcdk maix.tensor.Vector3i32.Vector3i32
|
||||
*/
|
||||
Vector3i32(int32_t x0, int32_t y0, int32_t z0)
|
||||
: Vector3<int32_t>(x0, y0, z0)
|
||||
@@ -126,40 +126,40 @@ namespace maix
|
||||
|
||||
/**
|
||||
* member x.
|
||||
* @maixpy maix.Vector3i32.x
|
||||
* @maixpy maix.tensor.Vector3i32.x
|
||||
*/
|
||||
// int32_t x;
|
||||
|
||||
/**
|
||||
* member y.
|
||||
* @maixpy maix.Vector3i32.y
|
||||
* @maixpy maix.tensor.Vector3i32.y
|
||||
*/
|
||||
// int32_t y;
|
||||
|
||||
/**
|
||||
* member z.
|
||||
* @maixpy maix.Vector3i32.z
|
||||
* @maixpy maix.tensor.Vector3i32.z
|
||||
*/
|
||||
// int32_t z;
|
||||
};
|
||||
|
||||
/**
|
||||
* Vector3 uint32_t type.
|
||||
* @maixpy maix.Vector3u32
|
||||
* @maixpy maix.tensor.Vector3u32
|
||||
*/
|
||||
class Vector3u32 : public Vector3<uint32_t> // we use class for we want to generate maixpy API, and the tool not suppoort using yet.
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
* @maixcdk maix.Vector3u32.Vector3u32
|
||||
* @maixcdk maix.tensor.Vector3u32.Vector3u32
|
||||
*/
|
||||
Vector3u32() : Vector3<uint32_t>() {}
|
||||
|
||||
/**
|
||||
* Construct Vector3u32 with 3 variables.
|
||||
* @maixpy maix.Vector3u32.__init__
|
||||
* @maixcdk maix.Vector3u32.Vector3u32
|
||||
* @maixpy maix.tensor.Vector3u32.__init__
|
||||
* @maixcdk maix.tensor.Vector3u32.Vector3u32
|
||||
*/
|
||||
Vector3u32(uint32_t x0, uint32_t y0, uint32_t z0)
|
||||
: Vector3<uint32_t>(x0, y0, z0)
|
||||
@@ -167,40 +167,40 @@ namespace maix
|
||||
|
||||
/**
|
||||
* member x.
|
||||
* @maixpy maix.Vector3u32.x
|
||||
* @maixpy maix.tensor.Vector3u32.x
|
||||
*/
|
||||
// uint32_t x;
|
||||
|
||||
/**
|
||||
* member y.
|
||||
* @maixpy maix.Vector3u32.y
|
||||
* @maixpy maix.tensor.Vector3u32.y
|
||||
*/
|
||||
// uint32_t y;
|
||||
|
||||
/**
|
||||
* member z.
|
||||
* @maixpy maix.Vector3u32.z
|
||||
* @maixpy maix.tensor.Vector3u32.z
|
||||
*/
|
||||
// uint32_t z;
|
||||
};
|
||||
|
||||
/**
|
||||
* Vector3 int16 type.
|
||||
* @maixpy maix.Vector3i16
|
||||
* @maixpy maix.tensor.Vector3i16
|
||||
*/
|
||||
class Vector3i16 : public Vector3<int16_t> // we use class for we want to generate maixpy API, and the tool not suppoort using yet.
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
* @maixcdk maix.Vector3i16.Vector3i16
|
||||
* @maixcdk maix.tensor.Vector3i16.Vector3i16
|
||||
*/
|
||||
Vector3i16() : Vector3<int16_t>() {}
|
||||
|
||||
/**
|
||||
* Construct Vector3i16 with 3 variables.
|
||||
* @maixpy maix.Vector3i16.__init__
|
||||
* @maixcdk maix.Vector3i16.Vector3i16
|
||||
* @maixpy maix.tensor.Vector3i16.__init__
|
||||
* @maixcdk maix.tensor.Vector3i16.Vector3i16
|
||||
*/
|
||||
Vector3i16(int16_t x0, int16_t y0, int16_t z0)
|
||||
: Vector3<int16_t>(x0, y0, z0)
|
||||
@@ -208,40 +208,40 @@ namespace maix
|
||||
|
||||
/**
|
||||
* member x.
|
||||
* @maixpy maix.Vector3i16.x
|
||||
* @maixpy maix.tensor.Vector3i16.x
|
||||
*/
|
||||
// int16_t x;
|
||||
|
||||
/**
|
||||
* member y.
|
||||
* @maixpy maix.Vector3i16.y
|
||||
* @maixpy maix.tensor.Vector3i16.y
|
||||
*/
|
||||
// int16_t y;
|
||||
|
||||
/**
|
||||
* member z.
|
||||
* @maixpy maix.Vector3i16.z
|
||||
* @maixpy maix.tensor.Vector3i16.z
|
||||
*/
|
||||
// int16_t z;
|
||||
};
|
||||
|
||||
/**
|
||||
* Vector3 uint16 type.
|
||||
* @maixpy maix.Vector3u16
|
||||
* @maixpy maix.tensor.Vector3u16
|
||||
*/
|
||||
class Vector3u16 : public Vector3<uint16_t> // we use class for we want to generate maixpy API, and the tool not suppoort using yet.
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
* @maixcdk maix.Vector3u16.Vector3u16
|
||||
* @maixcdk maix.tensor.Vector3u16.Vector3u16
|
||||
*/
|
||||
Vector3u16() : Vector3<uint16_t>() {}
|
||||
|
||||
/**
|
||||
* Construct Vector3u16 with 3 variables.
|
||||
* @maixpy maix.Vector3u16.__init__
|
||||
* @maixcdk maix.Vector3u16.Vector3u16
|
||||
* @maixpy maix.tensor.Vector3u16.__init__
|
||||
* @maixcdk maix.tensor.Vector3u16.Vector3u16
|
||||
*/
|
||||
Vector3u16(uint16_t x0, uint16_t y0, uint16_t z0)
|
||||
: Vector3<uint16_t>(x0, y0, z0)
|
||||
@@ -249,19 +249,19 @@ namespace maix
|
||||
|
||||
/**
|
||||
* member x.
|
||||
* @maixpy maix.Vector3u16.x
|
||||
* @maixpy maix.tensor.Vector3u16.x
|
||||
*/
|
||||
// uint16_t x;
|
||||
|
||||
/**
|
||||
* member y.
|
||||
* @maixpy maix.Vector3u16.y
|
||||
* @maixpy maix.tensor.Vector3u16.y
|
||||
*/
|
||||
// uint16_t y;
|
||||
|
||||
/**
|
||||
* member z.
|
||||
* @maixpy maix.Vector3u16.z
|
||||
* @maixpy maix.tensor.Vector3u16.z
|
||||
*/
|
||||
// uint16_t z;
|
||||
};
|
||||
|
||||
@@ -96,19 +96,19 @@ public:
|
||||
* accelerometer data
|
||||
* @maixpy maix.ext_dev.imu.IMUData.acc
|
||||
*/
|
||||
maix::Vector3f acc;
|
||||
maix::tensor::Vector3f acc;
|
||||
|
||||
/**
|
||||
* gyroscope data
|
||||
* @maixpy maix.ext_dev.imu.IMUData.gyro
|
||||
*/
|
||||
maix::Vector3f gyro;
|
||||
maix::tensor::Vector3f gyro;
|
||||
|
||||
/**
|
||||
* magnetometer data
|
||||
* @maixpy maix.ext_dev.imu.IMUData.mag
|
||||
*/
|
||||
maix::Vector3f mag;
|
||||
maix::tensor::Vector3f mag;
|
||||
|
||||
/**
|
||||
* temperature data
|
||||
@@ -233,7 +233,7 @@ public:
|
||||
* Empty string means not save. By default value is "default", means save calibration as id "default".
|
||||
* @maixpy maix.ext_dev.imu.IMU.calib_gyro
|
||||
*/
|
||||
Vector3f calib_gyro(uint64_t time_ms, int interval_ms = -1, const std::string &save_id = "default");
|
||||
tensor::Vector3f calib_gyro(uint64_t time_ms, int interval_ms = -1, const std::string &save_id = "default");
|
||||
|
||||
/**
|
||||
* Load Gyro calibration from file, if not found all value will be 0.
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
* @param save_id saved id from valib_gyro, default is "default".
|
||||
* @maixpy maix.ext_dev.imu.IMU.load_calib_gyro
|
||||
*/
|
||||
Vector3f load_calib_gyro(const std::string &save_id = "default");
|
||||
tensor::Vector3f load_calib_gyro(const std::string &save_id = "default");
|
||||
|
||||
/**
|
||||
* Save Gyro calibration to file.
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
* @param save_id saved id from valib_gyro, default is "default".
|
||||
* @maixpy maix.ext_dev.imu.IMU.save_calib_gyro
|
||||
*/
|
||||
err::Err save_calib_gyro(const Vector3f &calib, const std::string &save_id = "default");
|
||||
err::Err save_calib_gyro(const tensor::Vector3f &calib, const std::string &save_id = "default");
|
||||
|
||||
/**
|
||||
* @brief !!!Depracated!!!
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
std::vector<double> get_calibration();
|
||||
|
||||
public:
|
||||
Vector3f calib_gyro_data;
|
||||
tensor::Vector3f calib_gyro_data;
|
||||
|
||||
private:
|
||||
void* _param;
|
||||
|
||||
@@ -89,7 +89,6 @@ std::vector<ext_dev::imu::IMUInfo> get_imu_info()
|
||||
IMU::IMU(std::string driver, int i2c_bus, int addr, int freq, imu::Mode mode, imu::AccScale acc_scale,
|
||||
imu::AccOdr acc_odr, imu::GyroScale gyro_scale, imu::GyroOdr gyro_odr, bool block)
|
||||
{
|
||||
err::check_bool_raise(driver == "qmi8658", "Only support qmi8658 now");
|
||||
imu_param_t *param = (imu_param_t *)malloc(sizeof(imu_param_t));
|
||||
err::check_null_raise(param, "Failed to malloc param");
|
||||
|
||||
@@ -198,7 +197,7 @@ ext_dev::imu::IMUData IMU::read_all(bool calib_gryo, bool radian)
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector3f IMU::calib_gyro(uint64_t time_ms, int interval_ms, const std::string &save_id)
|
||||
tensor::Vector3f IMU::calib_gyro(uint64_t time_ms, int interval_ms, const std::string &save_id)
|
||||
{
|
||||
uint64_t start_ms = time::ticks_ms();
|
||||
uint64_t last_ms = 0;
|
||||
@@ -277,10 +276,10 @@ bool IMU::calib_gyro_exists(const std::string &save_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3f IMU::load_calib_gyro(const std::string &save_id)
|
||||
tensor::Vector3f IMU::load_calib_gyro(const std::string &save_id)
|
||||
{
|
||||
// load CALIBRATION_DATA_PATH2 with json
|
||||
Vector3f calib;
|
||||
tensor::Vector3f calib;
|
||||
calib.x = 0;
|
||||
calib.y = 0;
|
||||
calib.z = 0;
|
||||
@@ -313,7 +312,7 @@ Vector3f IMU::load_calib_gyro(const std::string &save_id)
|
||||
return calib;
|
||||
}
|
||||
|
||||
err::Err IMU::save_calib_gyro(const Vector3f &calib, const std::string &save_id)
|
||||
err::Err IMU::save_calib_gyro(const tensor::Vector3f &calib, const std::string &save_id)
|
||||
{
|
||||
json data;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ std::vector<cv::Point2f> render_pose(float pitch, float roll, float yaw, bool ra
|
||||
return projections;
|
||||
}
|
||||
|
||||
void draw_image(image::Image &img, Vector3f &angle, bool dir_cam)
|
||||
void draw_image(image::Image &img, tensor::Vector3f &angle, bool dir_cam)
|
||||
{
|
||||
float len = 0.35;
|
||||
int min_edge = std::min(img.width(), img.height());
|
||||
|
||||
Reference in New Issue
Block a user