This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pypilot
#28
Code:
        while True:
            t0 = time.time()
            data = boatimu.IMURead()
            if data:
                #sending data to signal k node server here
            server.HandleRequests()
            dt = time.time() - t0
            if dt > .1:
                time.sleep(dt);

25% usage sounds like one of the four raspberry pi cores is completely blocked. And looking at the code, this makes sense. The while does not sleep at all, if IMURead and HandleRequests are faster than 0.1 second.
I guess the other way around was meant?
if dt < .1:
  time.sleep(dt)

Still i find the variable sleep time amount weird.
Maybe time.sleep(.1-dt) makes more sense? Therefore IMURead() and HandleRequest are only called at most every .1 seconds.
Sorry, but i am not able to test this at the moment.
Reply


Messages In This Thread
Pypilot - by Sailoog - 2017-07-02, 01:14 PM
RE: Pypilot - by Sailoog - 2017-07-02, 01:22 PM
RE: Pypilot - by seandepagnier - 2017-07-02, 03:24 PM
RE: Pypilot - by Sailoog - 2017-07-02, 04:37 PM
RE: Pypilot - by Sailoog - 2017-07-02, 06:39 PM
RE: Pypilot - by seandepagnier - 2017-07-02, 07:09 PM
RE: Pypilot - by Sailoog - 2017-07-02, 07:05 PM
RE: Pypilot - by Sailoog - 2017-07-02, 08:21 PM
RE: Pypilot - by seandepagnier - 2017-07-02, 10:22 PM
RE: Pypilot - by Sailoog - 2017-07-04, 04:35 PM
RE: Pypilot - by seandepagnier - 2017-07-04, 04:58 PM
RE: Pypilot - by Sailoog - 2017-07-04, 05:58 PM
RE: Pypilot - by seandepagnier - 2017-07-04, 06:33 PM
RE: Pypilot - by Sailoog - 2017-07-04, 06:55 PM
RE: Pypilot - by Sailoog - 2017-07-05, 06:55 PM
RE: Pypilot - by seandepagnier - 2017-07-07, 03:57 PM
RE: Pypilot - by Sailoog - 2017-07-07, 07:02 PM
RE: Pypilot - by Sailoog - 2017-07-07, 07:08 PM
RE: Pypilot - by seandepagnier - 2017-07-08, 02:29 AM
RE: Pypilot - by Sailoog - 2017-07-10, 06:23 PM
RE: Pypilot - by seandepagnier - 2017-07-11, 01:44 AM
RE: Pypilot - by Sailoog - 2017-08-06, 08:41 PM
RE: Pypilot - by gaspbut - 2017-09-10, 08:50 AM
RE: Pypilot - by Sailoog - 2017-08-06, 09:31 PM
RE: Pypilot - by Sailoog - 2017-08-08, 07:04 PM
RE: Pypilot - by seandepagnier - 2017-08-10, 08:38 PM
RE: Pypilot - by Sailoog - 2017-08-11, 05:08 PM
RE: Pypilot - by lordzahl - 2017-08-12, 06:29 AM
RE: Pypilot - by waterman480 - 2017-08-11, 11:27 PM
RE: Pypilot - by waterman480 - 2017-08-12, 03:54 PM
RE: Pypilot - by seandepagnier - 2017-08-14, 07:14 PM
RE: Pypilot - by Sailoog - 2017-08-21, 11:05 AM
RE: Pypilot - by seandepagnier - 2017-08-23, 07:26 PM
RE: Pypilot - by jim321 - 2017-09-10, 09:13 AM
RE: Pypilot - by Sailoog - 2017-10-08, 01:54 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)