Skip to content

Camera() instantiation breaks stable usage of UltrasonicSensor() #367

Open
@duwudi

Description

@duwudi
from pitop import (
    Camera,
    UltrasonicSensor,
)
from time import sleep

camera = Camera(resolution=(640, 480))

ultrasonic = UltrasonicSensor("D3")

while True:
    print(f"Distance: {ultrasonic.distance}")
    sleep(0.1)

If the camera instantiation is commented out, the program runs normally and distance readings make sense.

With the camera, the following problems occur:

  • The first call to ultrasonic.distance hangs for 8-10 seconds. This hanging also happens sporadically throughout subsequent calls too.
  • The readings returned are unstable and do not represent the actual distance at all. For example, the distance returned with the hand at around 0.1m away from the sensor is 0.6m - the returned readings seem to span 0.6-1.0m regardless of the true distance.

Pin Factory Test: Problem occurs whether using the default pin factory or if using NativeFactory() as we did previously - so I don't think this is caused by a382aa5

htop screenshot whilst program running:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions