Skip to content

Commit

Permalink
pybricks.common.IMU: Change example to print G force.
Browse files Browse the repository at this point in the history
Since we changed the acceleration units to mm/s/s, the output values are
fairly large.

The Matrix repr function prints values up to 999, so this avoids
truncating the output.

It is also a good demo of scalar division for a Matrix / Vector.
  • Loading branch information
laurensvalk committed Apr 1, 2022
1 parent 5567289 commit f934fdd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/pup/hub_primehub/imu_read_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Initialize the hub.
hub = PrimeHub()

# Get the acceleration vector.
print(hub.imu.acceleration())
# Get the acceleration vector in g's.
print(hub.imu.acceleration() / 9810)

# Get the angular velocity vector.
print(hub.imu.angular_velocity())
Expand Down
4 changes: 2 additions & 2 deletions examples/pup/hub_shared/imu_read_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Initialize the hub.
hub = ExampleHub()

# Get the acceleration vector.
print(hub.imu.acceleration())
# Get the acceleration vector in g's.
print(hub.imu.acceleration() / 9810)

# Get the angular velocity vector.
print(hub.imu.angular_velocity())
Expand Down
4 changes: 2 additions & 2 deletions examples/pup/hub_technichub/imu_read_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Initialize the hub.
hub = TechnicHub()

# Get the acceleration vector.
print(hub.imu.acceleration())
# Get the acceleration vector in g's.
print(hub.imu.acceleration() / 9810)

# Get the angular velocity vector.
print(hub.imu.angular_velocity())
Expand Down

0 comments on commit f934fdd

Please sign in to comment.