Spaces:
Sleeping

File size: 3,955 Bytes
e039c53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from dataclasses import dataclass, field
from typing import List, Optional, Union

# Type alias
HeaderId = int

@dataclass
class AgvPosition:
    """Current position of the AGV on the map"""
    x: float
    y: float
    theta: float
    map_id: str
    position_initialized: bool
    map_description: Optional[str] = None
    localization_score: Optional[float] = None
    deviation_range: Optional[float] = None
    
    def to_dict(self):
        result = {
            "x": self.x,
            "y": self.y,
            "theta": self.theta,
            "mapId": self.map_id,
            "positionInitialized": self.position_initialized
        }
        if self.map_description is not None:
            result["mapDescription"] = self.map_description
        if self.localization_score is not None:
            result["localizationScore"] = self.localization_score
        if self.deviation_range is not None:
            result["deviationRange"] = self.deviation_range
        return result

@dataclass
class BoundingBoxReference:
    """Describes the loads position on the AGV in the vehicle coordinates"""
    x: float
    y: float
    z: float
    theta: Optional[float] = None
    
    def to_dict(self):
        result = {
            "x": self.x,
            "y": self.y,
            "z": self.z
        }
        if self.theta is not None:
            result["theta"] = self.theta
        return result

@dataclass
class ControlPoint:
    """Control point for trajectory"""
    x: float
    y: float
    weight: Optional[float] = None
    orientation: Optional[float] = None
    
    def to_dict(self):
        result = {
            "x": self.x,
            "y": self.y
        }
        if self.weight is not None:
            result["weight"] = self.weight
        if self.orientation is not None:
            result["orientation"] = self.orientation
        return result

@dataclass
class LoadDimensions:
    """Dimensions of the load's bounding box in meters"""
    length: float
    width: float
    height: Optional[float] = None
    
    def to_dict(self):
        result = {
            "length": self.length,
            "width": self.width
        }
        if self.height is not None:
            result["height"] = self.height
        return result

@dataclass
class NodePosition:
    """Node position"""
    x: float
    y: float
    map_id: str
    theta: Optional[float] = None
    allowed_deviation_xy: Optional[float] = None
    allowed_deviation_theta: Optional[float] = None
    map_description: Optional[str] = None
    
    def to_dict(self):
        result = {
            "x": self.x,
            "y": self.y,
            "mapId": self.map_id
        }
        if self.theta is not None:
            result["theta"] = self.theta
        if self.allowed_deviation_xy is not None:
            result["allowedDeviationXY"] = self.allowed_deviation_xy
        if self.allowed_deviation_theta is not None:
            result["allowedDeviationTheta"] = self.allowed_deviation_theta
        if self.map_description is not None:
            result["mapDescription"] = self.map_description
        return result

@dataclass
class Trajectory:
    """Trajectory defined as a NURBS"""
    degree: int
    knot_vector: List[float]
    control_points: List[ControlPoint]
    
    def to_dict(self):
        return {
            "degree": self.degree,
            "knotVector": self.knot_vector,
            "controlPoints": [cp.to_dict() for cp in self.control_points]
        }

@dataclass
class Velocity:
    """The AGVs velocity in vehicle coordinates"""
    vx: Optional[float] = None
    vy: Optional[float] = None
    omega: Optional[float] = None
    
    def to_dict(self):
        result = {}
        if self.vx is not None:
            result["vx"] = self.vx
        if self.vy is not None:
            result["vy"] = self.vy
        if self.omega is not None:
            result["omega"] = self.omega
        return result