Concept - soup1997/Study-Alone GitHub Wiki
control input(
μλμ°¨μ λ°ν΄μ μ₯μ°©λ wheel encoderμ μΌμ λ°μ΄ν°λ₯Ό μ΄μ©ν λͺ¨λΈ, λͺ¨μ  λͺ λ Ήμ μ€νν νμλ§ μΌμ κ°μ μ»μ μ μκΈ° λλ¬Έμ μΆμ μ μν΄ μ μ©νλ€.
- 
$u=<\delta_{rot1}, \delta_{rot2}, \delta{trans}>$ 
     
μλμ°¨μ 무κ²μ€μ¬ λλ νλ₯μ€μμ λΆμ°©λ imuμ κ°μ κ΄μ± μΌμλ₯Ό μ΄μ©ν λͺ¨λΈ
- 
$u=(v, w)^T$ , where$v$ is translation velocity and$w$ is rotational velocity    
νμ¬ stateμμμ μΌμ λ°μ΄ν°μ νλ₯ μ μλ―Ένλ©° Model for laser scannersμ κ²½μ° λ€μκ³Ό κ°λ€.
- 
$z_t=(z_t^1, \dots, z_t^k)$ : Scan$z$ consists of$K$ measurements.
- 
$p(z_t|x_t)=\Pi_{i=1}^kp(z_{t}^i|x_t)$ : Individual measurements are independent given the robot position
3μ°¨μ 곡κ°μμ SO(3) κ΅°μ μμ μ μ€μ¬μΌλ‘ νμ νλ μ°μ°μ λν κ΅°μ λ§νλ€. μ΄λ λ‘보ν±μ€μμ κ°μ²΄(rigid body)μ μμ§μ μ€ νμ μ νννλλ° μ£Όλ‘ μ¬μ©λλ€. rigid body motionμ΄λ 물체μ ννκ° λ³ννμ§ μμμ κ°λ, μλμ μΈ νμ λ, 거리 λ±μ΄ 보쑴λλ μμ§μμ μλ―Ένλ€.
- 
SO(3)κ΅°μ μΌλ°μ μΌλ‘ νμ νλ ¬(rotation matrix)λ₯Ό μ¬μ©νμ¬ νκΈ°νλ€.
- Quaternionμ μ¬μ©νμ¬ SO(3)λ₯Ό νκΈ°νλ λ°©λ² λν λ리 μ¬μ©λλ€.
- νμ νλ ¬μ μ§κ΅ μ±μ§: $R^TR=I=RR^T$ 
- νμ νλ ¬μ μνλ ¬μ μ μ§νλ ¬κ³Ό λμΌ: $R^{-1}=R^T$ 
- κ°μ²΄μ μμ§μ: $det(R)=1$ 
- ν©μ±μ νλ ¬μ κ³±μ
 μ°μ°: $R_1\cdot R_2=R_3\in SO(3)$ 
3D rotation matrices can be obtainded from these three using matrix multiplication.
Generally, ZYX rotation is used. yaw, pitch, and roll angles are 
- κΈ°μ€ μ’νκ³(Global Coordinate)μ XμΆ(Roll)μ κΈ°μ€μΌλ‘ $\gamma$ λ§νΌ νμ 
- κΈ°μ€ μ’νκ³(Global Coordinate)μ YμΆ(Pitch)μ κΈ°μ€μΌλ‘ $\beta$ λ§νΌ νμ 
- κΈ°μ€ μ’νκ³(Global Coordinate)μ ZμΆ(Yaw)μ κΈ°μ€μΌλ‘ $\alpha$ λ§νΌ νμ 

- Rotation matrix has has inverse matrix and transposed matrix which indicates roration in the opposite direction.
- Sets that satisfy the properties of rotation matrix belongs to SO(3)(Special Orthogonal Group).
- 
SO(3)groups can only express rotations. The 4X4 matrix must be considered to represent Translation, It should be extended to homogeneous coordinate.
- In this 4X4 matrix, the determinant = +1 of R(rotation), and the group that forms the affine rigid motion is called SE(3).

where 


- $q^{*}=q_w-\boldsymbol{q_v}$ 
- For unit quaternions, $||q||=1$ , and therefore$q^{-1}(inverse) = q^{*}(conjugate)$ .

- If the axis of rotation is the x-axis
$q_w = cos(\alpha/2)$ ,$q_x = sin(\alpha/2) * 1$ ,$q_y = sin(\alpha/2) * 0$ ,$q_z = sin(\alpha/2) * 0$ 
- If the axis of rotation is the y-axis
$q_w = cos(\alpha/2)$ ,$q_x = sin(\alpha/2) * 0$ ,$q_y = sin(\alpha/2) * 1$ ,$q_z = sin(\alpha/2) * 0$ 
- If the axis of rotation is the z-axis
$q_w = cos(\alpha/2)$ ,$q_x = sin(\alpha/2) * 0$ ,$q_y = sin(\alpha/2) * 0$ ,$q_z = sin(\alpha/2) * 1$ 
where 

#define _USE_MATH_DEFINES
#include <cmath>
struct Quaternion {
    double w, x, y, z;
};
struct EulerAngles {
    double roll, pitch, yaw;
};
// this implementation assumes normalized quaternion
// converts to Euler angles in 3-2-1 sequence
EulerAngles ToEulerAngles(Quaternion q) {
    EulerAngles angles;
    // roll (x-axis rotation)
    double sinr_cosp = 2 * (q.w * q.x + q.y * q.z);
    double cosr_cosp = 1 - 2 * (q.x * q.x + q.y * q.y);
    angles.roll = std::atan2(sinr_cosp, cosr_cosp);
    // pitch (y-axis rotation)
    double sinp = std::sqrt(1 + 2 * (q.w * q.y - q.x * q.z));
    double cosp = std::sqrt(1 - 2 * (q.w * q.y - q.x * q.z));
    angles.pitch = 2 * std::atan2(sinp, cosp) - M_PI / 2;
    // yaw (z-axis rotation)
    double siny_cosp = 2 * (q.w * q.z + q.x * q.y);
    double cosy_cosp = 1 - 2 * (q.y * q.y + q.z * q.z);
    angles.yaw = std::atan2(siny_cosp, cosy_cosp);
    return angles;
}- nμ°¨μμ μ’νλ₯Ό n+1κ°μ μ’νλ‘ λνλ΄λ κ²
- μ’μΈ‘μ Homogeneous coordinateμ°μΈ‘μCartesian(Euclidean) coordinateμ μλ―Ένλ€.
- 3μ°¨μμμμ νμ νλ ¬(Rotation matrix)μ νν μ΄λνλ ¬(translation matrix) λ€μκ³Ό κ°μ΄ μ μλλ€.
- λ°λΌμ 3μ°¨μμμμ μ΅μ’ μ μΌλ‘ 물체μ νμ κ³Ό μ΄λμ νλ²μ νννλ homogeneous transformation matrixλ λ€μκ³Ό κ°λ€.