-
Notifications
You must be signed in to change notification settings - Fork 7
What happens if you call getBulkInputData() multiple times? #9
Comments
Any time that |
Is there a good way to call In a basic Another option I am considering would be to wrap Just wondering if you have any suggestions or thoughts. Perhaps these calls are so much faster it doesn't matter if you make them a few extra times. |
@EddieDL There is no such concept of a "hardware cycle" when using an Expansion Hub. Unlike Modern Robotics which has background threads for each module and periodically reads/writes, every single API call, e.g., If your linear opmode is structured in the form of a state machine, I would update the bulk data once per iteration of the master state machine. If you're not using a state machine, then the only option I can think of other than the time-throttled method you mentioned, would be to have a background thread that continually polls bulk data and provides your main thread access to it through a |
Seems like I was stuck still thinking there was a background hardware thread, even when using the Expansion Hub. I guess this makes it even more beneficial to move to the bulk read approach. I am pretty sure we are going to need to implement the time-throttling I mentioned. Do you have any suggestion for a sane throttle? Based on reading and your comment ftctechnh/ftc_app#542 (comment), I was thinking about making it 6-10 ms. I thought about making it the update interval on the Rev Module, but I wasn't exactly sure what that is. |
@EddieDL Keep in mind that each motor set power command takes 3ms (x4 motors = 12ms). Also doing an IMU read will cost you about 7ms. So I would recommend somewhere in the range of a 20ms throttle. I'm not entirely sure what you mean by "the update interval on the Rev Module". The "update rate" to user code is entirely defined by how many bus transactions you're doing. If you're only doing a single bulk read (and nothing else), you can push in excess of 300Hz. But as soon as you start adding more commands that plummets sharply. If you're referring to the internal update rate inside the Hub's SOC, I think for DIO that's 100Hz, not sure about encoders. But in any case, with 4 motors and bulk read, you will never be able to go faster than 66Hz.... |
That is very helpful. I was asking about the internal rate of refresh for various components inside the Hub. My thinking was to potentially use that as an input to calculating a good throttle. Now I understand what you are saying a little bit more and I also see why there could be HUGE gains by expanding the SDK and Hub to support bulk writes, data exchange, bulk i2c reads, etc. In my case, we are going to have the following configuration:
If I understand the math correctly, that is 4 * 3 ms + 2 * 3 ms + 7 ms = 25 ms. Does that seem right? Thanks again for all the help. |
Yes that seems right, in theory anyway. What I would suggest is to make a Linear OpMode with a loop that reads those things, and average the loop time over maybe 250-1000 iterations. Then make your throttle ever so slightly faster. Also, make sure to use SDK v5.3 and firmware 1.8.2 as they contain optimizations for I2C reads. |
What gluten free did was they polled the bulk data in their robot class then set all the motors |
@David10238 oh, reading once per iteration is absolutely the best way to do it. But unless your code is written as a state machine, that's not possible. |
Thank you for all of the help on this. I have implemented something that will work for us, based on all of your input. |
We have created several sub-system classes that utilize sensor data from the expansion hub. We have switched to getting this data using
getBulkinputData()
. Does the logic ofgetBulkInputData()
have any logic to ensure multiple hardware calls are being made in a given "update cycle" or do we need to figure that out in our implementation?The text was updated successfully, but these errors were encountered: