This commit is contained in:
Đăng Nguyễn
2025-10-13 13:17:32 +07:00
parent 511614df72
commit b2df5b22b7
66 changed files with 1957 additions and 376 deletions

View File

@@ -2,22 +2,29 @@
public enum RootStateType
{
Booting,
Operational,
System,
Auto,
Manual,
Service,
Stop,
Fault,
}
public enum OperationalStateType
public enum SystemStateType
{
Initializing,
Standby,
Shutting_Down,
}
public enum AutomationStateType
public enum AutoStateType
{
Idle,
Executing,
Paused,
Charging,
Error,
Holding,
Canceling,
Recovering,
Remote_Override,
}
@@ -27,13 +34,60 @@ public enum ManualStateType
Active,
}
public enum SafetyStateType
public enum ServiceStateType
{
Init,
Run_Ok,
SS1,
STO,
PDS,
SLS,
Error,
Idle,
Active,
}
public enum StopStateType
{
EMC,
Protective,
Manual,
}
public enum FaultStateType
{
Navigation,
Localization,
Shielf,
Battery,
Driver,
Peripherals,
Safety,
Communication,
}
public enum ExecutingStateType
{
Planning,
Moving,
ACT,
}
public enum ACTStateType
{
Docking,
Docked,
Charging,
Undocking,
Loading,
Unloading,
TechAction,
}
public enum MoveStateType
{
Navigation,
Avoidance,
Approach,
Tracking,
Repositioning,
}
public enum PlanStateType
{
Task,
Path,
}

View File

@@ -4,6 +4,14 @@ namespace RobotApp.Common.Shares;
public static class MathExtensions
{
public static double NormalizeAngle(double angle)
{
angle = angle % 360;
if (angle > 180) angle -= 360;
else if (angle < -180) angle += 360;
return angle;
}
public static (double x, double y) CurveDegreeTwo(double t, double x1, double y1, double controlPointX, double controlPointY, double x2, double y2)
{
var x = (1 - t) * (1 - t) * x1 + 2 * t * (1 - t) * controlPointX + t * t * x2;
@@ -77,4 +85,21 @@ public static class MathExtensions
}
return distance;
}
public static double GetVectorAngle(double originNodeX, double originNodeY, double vector1X, double vector1Y, double vector2X, double vector2Y)
{
double BA_x = vector1X - originNodeX;
double BA_y = vector1Y - originNodeY;
double BC_x = vector2X - originNodeX;
double BC_y = vector2Y - originNodeY;
// Tính độ dài của các vector AB và BC
double lengthAB = Math.Sqrt(BA_x * BA_x + BA_y * BA_y);
double lengthBC = Math.Sqrt(BC_x * BC_x + BC_y * BC_y);
// Tính tích vô hướng của AB và BC
double dotProduct = BA_x * BC_x + BA_y * BC_y;
if (lengthAB * lengthBC == 0) return 0;
if (dotProduct / (lengthAB * lengthBC) > 1) return 0;
if (dotProduct / (lengthAB * lengthBC) < -1) return 180;
return Math.Acos(dotProduct / (lengthAB * lengthBC)) * (180.0 / Math.PI);
}
}