Skip to content

Ultrasonic sensor doesn't return centimeters for distance_centimeters value in US-DIST-CM mode #329

@marnovdm

Description

@marnovdm
  • ev3dev version: 4.4.68-20-ev3dev-ev3
  • ev3dev-lang-python version: not sure how to get this info? Came installed with latest jessie ev3dev release

When using the ultrasonic sensor the distance doesn't seem to be in centimeters. The brickman tool on the ev3 does show the correct value when I read the sensor there. In python code I have to divide ultrasonic.distance_centimeters by 10 to get actual centimeters. A simple test case:

robot@ev3dev:/usr/lib/python3/dist-packages/ev3dev$ python3
Python 3.4.2 (default, Oct  8 2014, 14:47:30)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ev3dev.ev3 as ev3
>>> ultrasonic = ev3.UltrasonicSensor('in4')
>>> ultrasonic.distance_centimeters
326

While the display shows 32.6 cm (which corresponds with real world distance from the sensor). I would expect to get either a floating point like 32.6 for distance_centimeters method or a changed method name like distance_milimeters or something. This seems incorrect, or am I doing something wrong? Workaround is easy enough and I'm having lots of fun programming my EV3 with python but thought I'd at least report this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions