This commit is contained in:
samfreund
2025-11-26 21:10:02 -06:00
parent 5457db947e
commit f022130bfa
12 changed files with 249 additions and 74 deletions

View File

@@ -70,19 +70,11 @@ class Packet:
return retVal
def getData(self) -> bytes:
"""
* Returns the packet data.
*
* @return The packet data.
"""
"""Return the packet data."""
return self.packetData
def setData(self, data: bytes):
"""
* Sets the packet data.
*
* @param data The packet data.
"""
"""Set the packet data."""
self.clear()
self.packetData = data
self.size = len(self.packetData)
@@ -101,74 +93,42 @@ class Packet:
return value
def decode8(self) -> int:
"""
* Returns a single decoded byte from the packet.
*
* @return A decoded byte from the packet.
"""
"""Return a single decoded byte from the packet."""
return self._decodeGeneric("<b", 1)
def decode16(self) -> int:
"""
* Returns a single decoded short from the packet.
*
* @return A decoded short from the packet.
"""
"""Return a single decoded short from the packet."""
return self._decodeGeneric("<h", 2)
def decodeInt(self) -> int:
"""
* Returns a decoded int (32 bytes) from the packet.
*
* @return A decoded int from the packet.
"""
"""Return a decoded 32-bit integer from the packet."""
return self._decodeGeneric("<l", 4)
def decodeFloat(self) -> float:
"""
* Returns a decoded float from the packet.
*
* @return A decoded float from the packet.
"""
"""Return a decoded float from the packet."""
return self._decodeGeneric("<f", 4)
def decodeLong(self) -> int:
"""
* Returns a decoded int64 from the packet.
*
* @return A decoded int64 from the packet.
"""
"""Return a decoded 64-bit integer from the packet."""
return self._decodeGeneric("<q", 8)
def decodeDouble(self) -> float:
"""
* Returns a decoded double from the packet.
*
* @return A decoded double from the packet.
"""
"""Return a decoded double from the packet."""
return self._decodeGeneric("<d", 8)
def decodeBoolean(self) -> bool:
"""
* Returns a decoded boolean from the packet.
*
* @return A decoded boolean from the packet.
"""
"""Return a decoded boolean from the packet."""
return self.decode8() == 1
def decodeDoubleArray(self, length: int) -> list[float]:
"""
* Returns a decoded array of floats from the packet.
"""
"""Return a decoded list of doubles of the given length from the packet."""
ret = []
for _ in range(length):
ret.append(self.decodeDouble())
return ret
def decodeShortList(self) -> list[int]:
"""
* Returns a decoded array of shorts from the packet.
"""
"""Return a decoded list of shorts from the packet (length-prefixed)."""
length = self.decode8()
ret = []
for _ in range(length):
@@ -176,11 +136,7 @@ class Packet:
return ret
def decodeTransform(self) -> Transform3d:
"""
* Returns a decoded Transform3d
*
* @return A decoded Tansform3d from the packet.
"""
"""Return a decoded Transform3d from the packet."""
x = self.decodeDouble()
y = self.decodeDouble()
z = self.decodeDouble()

View File

@@ -261,18 +261,18 @@ class PhotonPoseEstimator:
def update(
self, cameraResult: Optional[PhotonPipelineResult] = None
) -> Optional[EstimatedRobotPose]:
"""
Updates the estimated position of the robot. Returns empty if:
"""Update the estimated robot position.
- The timestamp of the provided pipeline result is the same as in the previous call to
``update()``.
Returns empty if one of the following is true:
- No targets were found in the pipeline results.
- The timestamp of the provided pipeline result is the same as in the previous call to
``update()``.
- No targets were found in the pipeline results.
:param cameraResult: The latest pipeline result from the camera
:param cameraResult: The latest pipeline result from the camera.
:returns: an :class:`EstimatedRobotPose` with an estimated pose, timestamp, and targets used to
create the estimate.
:returns: An :class:`EstimatedRobotPose` with an estimated pose, timestamp, and targets used
to create the estimate, or ``None`` if no estimate could be made.
"""
if not cameraResult:
if not self._camera:

View File

@@ -306,14 +306,13 @@ class SimCameraProperties:
:param a: The initial translation of the line
:param b: The final translation of the line
:returns: A Pair of Doubles. The values may be null:
:returns: A pair of floats (t_min, t_max) where each may be ``None``:
- {Double, Double} : Two parametrized values(t), minimum first, representing which
segment of the line is visible in the camera frustum.
- {Double, null} : One value(t) representing a single intersection point. For example,
the line only intersects the intersection of two adjacent viewplanes.
- {null, null} : No values. The line segment is not visible in the camera frustum.
"""
- ``(float, float)``: Two t values (minimum first) representing the visible segment.
- ``(float, None)``: A single intersection point.
- ``(None, None)``: No intersection; the segment is not visible.
"""
# translations relative to the camera
relA = camRt.applyTranslation(a)