gschwiersch
Posts: 6
Joined: Fri Jun 02, 2017 3:17 pm

sleep vs. timedelta

Tue Dec 19, 2017 7:04 pm

Hi,

For the AstroPi competition, my students would like to pause their script between readings. My students are on the website: https://projects.raspberrypi.org/en/pro ... ata-logger

"Normally in such situations you would use a sleep() function to pause the script. However, this can result in inaccurate readings from some of the Sense HAT’s orientation sensors, which need to be regularly polled.

To get around this, you can use timedelta to check the time difference between two readings."

Is there a preference for using the sleep function or the timedelta? The students are not using the orientation sensor.

Thanks,
Gail

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1661
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
Contact: Website Twitter

Re: sleep vs. timedelta

Wed Dec 20, 2017 10:57 am

Hi Gail

Okay the point there is that some of the functions, specifically the orientation ones are based on something called a kalman filter - which is where the pitch, roll and yaw angles are stored in memory and are updated each time you read from the sensor.

If you don't read the sensors often enough, the result you get back lags behind the movement the Sense HAT has gone through.

So what it's suggesting to do is keep reading the sensors constantly but then use timedelta to decide when you store the measurement in the csv file. It's not the same as sleep which actually stops the code running for a specified time.

Here's a link to the point in the Astro Pi webinar where I explain this (if it helps): https://www.youtube.com/watch?v=WYjaAZcWIPg&t=4390

If you're not using the orientation or get_orientation functions, and are instead using the _raw ones then you don't need to worry about this as those functions don't use a kalman filter to give you the data.

I hope this helps!
Dave

gschwiersch
Posts: 6
Joined: Fri Jun 02, 2017 3:17 pm

Re: sleep vs. timedelta

Fri Jan 12, 2018 8:21 pm

Thanks!

Return to “Astro Pi”

Who is online

Users browsing this forum: iticus and 2 guests