scirodev 0.5.4__tar.gz → 0.5.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scirodev
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Summary: PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev
5
5
  Author: Thomas Schank
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scirodev"
7
- version = "0.5.4"
7
+ version = "0.5.6"
8
8
  description = "PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,7 +1,8 @@
1
1
  """sciro.hubs -- the PeakHub.
2
2
 
3
3
  On the hub this module re-exports ``pybricks.hubs`` unchanged; the stub adds what
4
- the upstream stubs lack: the ``PeakHub`` class and its ``display.device()``.
4
+ the upstream stubs lack: the ``PeakHub`` class, its ``display.device()``, and the
5
+ ``ThisHub`` alias.
5
6
  """
6
7
 
7
8
  from __future__ import annotations
@@ -150,3 +151,32 @@ class PeakHub:
150
151
  broadcast_channel: Channel for broadcasting data (0 .. 255).
151
152
  observe_channels: Channels to observe.
152
153
  """
154
+
155
+
156
+ #: The hub this program is running on.
157
+ #:
158
+ #: Every Pybricks firmware compiles in exactly one hub class and exports it
159
+ #: under several names: the generic ``ThisHub``, the hub's own name, and any
160
+ #: aliases. On PeakHub firmware ``ThisHub``, :class:`PeakHub`, ``PrimeHub`` and
161
+ #: ``InventorHub`` are therefore all the *same* class object -- this is resolved
162
+ #: when the firmware is built, not by detecting anything at run time.
163
+ #:
164
+ #: Use it for code that should run unchanged on whichever hub is in front of
165
+ #: you, which is mostly bench and test scripts::
166
+ #:
167
+ #: from sciro.hubs import ThisHub
168
+ #:
169
+ #: hub = ThisHub()
170
+ #: print(hub.imu.heading(), hub.imu.tilt())
171
+ #:
172
+ #: Prefer :class:`PeakHub` when a program is specific to this hub anyway: it
173
+ #: says so, and it reads better than a generic name.
174
+ #:
175
+ #: Note the difference between the REPL and a downloaded program. The REPL is
176
+ #: started with everything auto-imported and with a ready-made ``hub`` instance
177
+ #: already created, so there ``hub.imu.heading()`` just works. A downloaded
178
+ #: program gets neither: it must import what it uses and construct the hub, as
179
+ #: above, and ``print(hub)`` there raises ``NameError``. (In the firmware this
180
+ #: is ``pb_package_pybricks_init(true)`` for the REPL versus ``false`` for
181
+ #: everything else.)
182
+ ThisHub = PeakHub
@@ -73,19 +73,74 @@ class DriveBase(_DriveBase):
73
73
  upstream meaning: continue at the drive speed.
74
74
  """
75
75
 
76
+ def turn( # type: ignore[override]
77
+ self,
78
+ angle: Number,
79
+ then: Stop = Stop.HOLD,
80
+ wait: bool = True,
81
+ absolute: bool = False,
82
+ turn_rate: Optional[Number] = None,
83
+ ) -> MaybeAwaitable:
84
+ """turn(angle, then=Stop.HOLD, wait=True, absolute=False, turn_rate=None)
85
+
86
+ Turns in place, as in Pybricks, with one PeakHub extension:
87
+
88
+ ``turn_rate``: turn rate in deg/s for this move only; ``None`` uses the
89
+ ``turn_rate`` setting, which is left untouched either way.
90
+
91
+ ``absolute=True`` turns *to* the given heading rather than *by* it,
92
+ taking the nearest whole-turn equivalent, so the correction is always
93
+ within +/-180 degrees (the same rule as ``straight(heading=)``).
94
+ """
95
+
76
96
  def curve(
77
97
  self,
78
98
  radius: Number,
79
99
  angle: Number,
80
100
  then: Stop = Stop.HOLD,
81
101
  wait: bool = True,
102
+ speed: Optional[Number] = None,
103
+ exit_speed: Number = 0,
82
104
  ) -> MaybeAwaitable:
83
- """curve(radius, angle, then=Stop.HOLD, wait=True)
105
+ """curve(radius, angle, then=Stop.HOLD, wait=True, speed=None, exit_speed=0)
84
106
 
85
107
  Drives an arc of ``angle`` degrees along a circle of ``radius`` mm.
86
- The firmware still has this method, but the ``pybricks`` stubs dropped
87
- it in favor of :meth:`arc`, so it is declared here to keep it usable
88
- without a type error. Prefer ``arc()`` in new code.
108
+ Upstream dropped this method in favour of :meth:`arc`, but the firmware
109
+ still has it, so it is declared here to keep it usable without a type
110
+ error. ``arc()`` takes the same extensions and is preferred in new code.
111
+
112
+ ``speed``: drive speed in mm/s along the arc for this move only. The
113
+ matching turn rate is derived from it, so the linear speed is what
114
+ governs the duration; ``None`` uses the ``straight_speed`` and
115
+ ``turn_rate`` settings.
116
+
117
+ ``exit_speed``: speed in mm/s the robot has when it reaches the end of
118
+ the arc. The *turn rate is brought to zero* at that point, so the robot
119
+ leaves on the tangent and keeps driving straight at ``exit_speed``
120
+ until the next command. This makes a curve-to-straight handover smooth;
121
+ without it a continuing move keeps rotating at the arc's turn rate and
122
+ the next command has to cancel that rotation. The price is that the
123
+ last fraction of the path is slightly flatter than a true arc. Implies
124
+ ``then=Stop.NONE``; any other explicit ``then`` raises ``ValueError``.
125
+ """
126
+
127
+ def arc( # type: ignore[override]
128
+ self,
129
+ radius: Number,
130
+ angle: Optional[Number] = None,
131
+ distance: Optional[Number] = None,
132
+ then: Stop = Stop.HOLD,
133
+ wait: bool = True,
134
+ speed: Optional[Number] = None,
135
+ exit_speed: Number = 0,
136
+ ) -> MaybeAwaitable:
137
+ """arc(radius, angle=None, distance=None, then=Stop.HOLD, wait=True, speed=None, exit_speed=0)
138
+
139
+ Drives an arc, as in Pybricks, with the same two PeakHub extensions as
140
+ :meth:`curve`: ``speed`` in mm/s for this move only (the turn rate is
141
+ derived from it), and ``exit_speed``, which ends the arc at that speed
142
+ with the turn rate at zero so the robot exits on the tangent and keeps
143
+ driving straight. ``exit_speed`` implies ``then=Stop.NONE``.
89
144
  """
90
145
 
91
146
  def heading_target(self, angle: Optional[Number] = None) -> Optional[float]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scirodev
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Summary: PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev
5
5
  Author: Thomas Schank
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes