Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Delay between different Infrared Sensor modes #62

Closed
TheVinhLuong102 opened this issue Jun 21, 2020 · 4 comments
Closed

[Question]: Delay between different Infrared Sensor modes #62

TheVinhLuong102 opened this issue Jun 21, 2020 · 4 comments
Labels
documentation Improvements or additions to documentation platform: EV3 Issues related to LEGO MINDSTORMS EV3 support Request for technical support for a problem that is not a bug or feature request topic: sensors Issues involving sensors

Comments

@TheVinhLuong102
Copy link
Sponsor

Hi @laurensvalk @dlech I have programmed the Ev3rstorm with both PyBricks2 and EV3Dev2 and would like to report significantly slower execution by PyBricks2 than by EV3Dev2. My 2 programs are attached for your review.

Ev3rstorm-PyBricks2-vs-EV3Dev2.zip

The 2 programs are trying to perform the same capabilities:

  • Driving around by the IR Beacon
  • Detect objects by the IR Sensor
  • Blast the bazooka when the Touch Sensor is pressed/bumped

Each of these activities is conditioned on certain "if"s, and the activities are arranged sequentially in a main "while True" loop. No multiprocessing/threading is used.

When I execute the EV3Dev2 program, the performance is pretty smooth: the Ev3rstorm is very responsive to sensory stimuli and actuates the various tricks satisfactorily.

However, when I run the PyBricks2 program, the Ev3rstorm's responses are very laggy/slow, suggesting that each loop in the "while True" takes a significantly longer time to execute.

Could you let me know how I can go about troubleshooting this? Thank you @laurensvalk @dlech .

@laurensvalk
Copy link
Member

laurensvalk commented Jun 21, 2020

The infrared sensor takes about 1 second to switch between modes. It is recommended that you use only 1 mode in your program or loop.

During that 1 second switch, the sensor gives unreliable data. This is a known hardware issue that cannot be fixed in software.

For Pybricks, we made the decision to wait for reliable data to come in. This is the same as with the official LEGO EV3-G Labview implementation.

It sounds like ev3dev2 does not do that.

If you want to get the raw sensor data without fixes like these, you can use the iodevices.LUMPDevice class. Then it will probably be the same as ev3dev2.

I hope you don't mind if I change the title of this topic. That will make it easier for other people with the same InfaredSensor latency problem to find this issue. I'm also going to move it to the support issue tracker - this belongs there.

@laurensvalk laurensvalk changed the title Significant latency difference between PyBricks2 vs. EV3Dev2 [Question]: Delay between different Infrared Sensor modes Jun 21, 2020
@laurensvalk laurensvalk transferred this issue from pybricks/pybricks-api Jun 21, 2020
@laurensvalk laurensvalk added platform: EV3 Issues related to LEGO MINDSTORMS EV3 support Request for technical support for a problem that is not a bug or feature request labels Jun 21, 2020
@dlech dlech added the topic: sensors Issues involving sensors label Jun 21, 2020
@TheVinhLuong102
Copy link
Sponsor Author

TheVinhLuong102 commented Jun 21, 2020

Thanks @laurensvalk. I was aware of ev3dev/ev3dev#1401 but didn't make the mental connection :) I can confirm now that removing one of the IR-related activities made the delay go away in my PyBricks Ev3rstorm.

Are you considering adding your recommendations above to the PyBricks documentation? These issues and the corresponding technical decisions are not obvious to most users, and others may encounter difficulties from time to time if they are unaware.

@laurensvalk
Copy link
Member

Yes, so let's keep this issue open until we've added that, thanks.

@laurensvalk laurensvalk added the documentation Improvements or additions to documentation label Jun 21, 2020
@laurensvalk
Copy link
Member

Documented in https://github.com/pybricks/pybricks-api.

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation platform: EV3 Issues related to LEGO MINDSTORMS EV3 support Request for technical support for a problem that is not a bug or feature request topic: sensors Issues involving sensors
Projects
None yet
Development

No branches or pull requests

3 participants