OCCRA
Go to Post ...there is a difference between the correct call and the right call. - Michael Corsetto [more]
Home
Go Back   Chief Delphi > Technical > Sensors
CD-Media  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-08-2018, 04:17 PM
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 19
sailorjoe will become famous soon enough
Post New Motion Sensor

In the summer of 2017, a company called Bitcraze, makers of the Crazyflie drone, announced a new motion sensor for general purpose use. This product is their Flow Breakout board. We tried to use this sensor on our robot for the 2018 season. The attached white paper describes what we learned about how to get started using the sensor. In total it took several months to figure out how to use the sensor correctly, because the sample program from the vendor was incorrect (still is), and because we didn't pay proper reverence to the sensor chip's SPI interface timing requirements, assuming the RoboRio SPI interface would be just fine. If you decide to use this sensor, and we do recommend it, you will be months ahead if take advantage of what we learned the hard way. We would love to hear what you learn if you use this new sensor, too.
Attached Files
File Type: doc FlowSensorWhitePaper.doc (82.0 KB, 127 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 09-08-2018, 05:29 PM
Brian M's Avatar
Brian M Brian M is offline
Design Lead
FRC #1360 (Orbit Robotics)
Team Role: CAD
 
Join Date: Feb 2017
Rookie Year: 2012
Location: Ontario, Canada
Posts: 328
Brian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond reputeBrian M has a reputation beyond repute
Re: New Motion Sensor

This sensor seems extremely useful, thank you for sharing! I read through your white paper and it seems like you have been able to get readings and should have been able to use it on the real field for an auto, but viewing your most recent matches it seems your team still only had a simple drive forward auto. Have you been able to develop this further and create accurate auto modes or is just testing the sensor as far as you have gotten?
__________________
2016 - Rah Cha Cha Ruckus Winners (3015 & 4039)
2017 - Industrial Design (Durham), Entrepreneurship (McMaster), Quality Award (Ontario DCMPS)
2018 - Georgian District Winner (1305 & 6864) + Innovation in Control, York District Winner (1325 & 6140) + Chairmans Award, Ont DCMP Excellence in Engineering


Reply With Quote
  #3   Spotlight this post!  
Unread 09-08-2018, 05:40 PM
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 19
sailorjoe will become famous soon enough
Re: New Motion Sensor

Thank you for your interest, Brian. We had the sensor mounted on the competition robot, but because of the problems described in the paper, we really never got it working correctly until after the season was finished. It was in the post-season school year that we added the timing delays, rearranged the register read sequence, and added the squal and shutter variables. Because the Arduino code "appeared" to work, and because we "appeared" to get good readings three times out of four, the diagnostic process took us down a lot of dead ends. So you're seeing about six months of trial and error learning collapsed into a paper. I hope the team decides to use the sensor this year for better autonomous performance.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-20-2018, 12:22 AM
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 19
sailorjoe will become famous soon enough
Re: New Motion Sensor

The attachment herein has the spreadsheet we used to capture and analyze the test data for the Flow Motion sensor on the Arduino. I have it in xls format, but we did it originally with OpenOffice. Not sure if that will cause problems.
By way of explanation, Sheets 1 through 7 show the data from the sensor with different loop delay values. You can see the spikey data, but at this point, these can be ignored.
Sheet 8 is where most of the good stuff resides. At this point the software library problem had been solved. The left columns are the ascii data from the sensor via the Arduino. The next columns are the same data in numeric form. The column called "Rounds" is an Arduino count of times through a "sensor ready to read" loop, and its not likely useful any longer.
Then there is the same data through a low pass filter with half second time constant that can be adjusted. The graph shows motion going out and back to zero.
Under the top graph is a sorted list of runs made sequentially, in one direction only. The table is sorted by the number of readings, which goes down as the speed goes up for the fixed distance. To the left of the table is a graph of the same data.
Sheet 9 is the data from just one run of the Y axis, and we see no surprises.
Sheet 10 is a single run by turning (spinning by hand) the sensor. No surprises there either, so far.
I hope this provides some enlightenment on how to begin to interpret the data from the sensor. We certainly have more work to do to understand it before build season.
Attached Files
File Type: xls FlowMotionTests.xls (284.5 KB, 16 views)
Reply With Quote
  #5   Spotlight this post!  
Unread 12-04-2018, 04:21 AM
dannytix dannytix is offline
Registered User
FRC #0568 (Nerds of the North)
Team Role: Mentor
 
Join Date: Dec 2018
Rookie Year: 2007
Location: Anchorage, AK
Posts: 2
dannytix is an unknown quantity at this point
Thumbs up Re: New Motion Sensor

sailerjoe: After years of lurking on CD, I registered just to say thank you for sharing this! We also purchased a couple of these sensors last year, and had to throw in the towel

Quickly scanning through your code, it looks like the key piece we were missing was reading all of the registers in order. I'll try to get some team members on integrating your paper into our code and report back if they find anything interesting.

Our solution to the timing problem was to tap directly into the underlying C libraries to use Linux SPI functions which allow you to add a delay directly. Reliable timing and no extra pins; at the cost of an extra dependency through JNA. We were able to perform basic communication this way, but the motion register readings never made sense. Now I know why (...I hope...)

If you're interested in this approach, it's on the Team 568 GitHub. One difference that stands out is that - by my reading (and recollection) of SPI mode 3 - we should have been setting spiFlow.setClockActiveLow() and spiFlow.setSampleDataOnRising(). However - due to a WPILib bug - the 568 code used setSampleDataOnFalling(); while your team used setClockActiveHigh(). It's equally possible that your team tripped on the same bug we did and chose the opposite fix; or that my team just read the definition wrong - the wikipedia article is a bit hard to parse. Either way, I wanted to point out that the WPILib bug was fixed over the Summer, and - if I'm not mistaken - you should migrate to setClockActiveLow() and the new setSampleDataOnTrailingEdge() method instead. If I am mistaken, I'd appreciate your input all the more.

Regards,
Danny Tix
Mentor - Team 568
Reply With Quote
  #6   Spotlight this post!  
Unread 12-12-2018, 12:43 AM
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 19
sailorjoe will become famous soon enough
Re: New Motion Sensor

Thank you, Danny, for your thoughts on using the Flow Motion Sensor. I rather like how you solved the timing problem, but for now, I think we will stick with what we have since it works and we already have the cable built.
I agree that the wikipedia article is a bit tricky, as is the Arduino article for the same topic. Our initial settings for SPI Mode 3 didn't work as expected. We finally just tried a number of combinations of settings until we found one that worked, which is what we have in the published code. Thanks for letting us know about the bug fix. We will have to take another look at the settings again, and we will republish the code if it needs to be changed.
Looking at your code, on lines 177 and 191, I see timing delays specified in microseconds. My understanding was that delays less than 1 millisecond resolved to just 1 millisecond delays, using the Timer.delay() function. Is this not correct? I asked this question in the white paper, too. We had to use delay loops in the code, but specific delay statements like yours would be better if they are accurate.
Reply With Quote
  #7   Spotlight this post!  
Unread 12-12-2018, 04:16 AM
dannytix dannytix is offline
Registered User
FRC #0568 (Nerds of the North)
Team Role: Mentor
 
Join Date: Dec 2018
Rookie Year: 2007
Location: Anchorage, AK
Posts: 2
dannytix is an unknown quantity at this point
Re: New Motion Sensor

Joe - thank you again for your valuable insight. It appears that you are right about Timer.delay() only supporting millisecond accuracy. It's just a simple wrapper around the less precise version of Thread.sleep().

That still leaves the (supposedly) nanosecond accurate overload of Thread.sleep() though. Do you know if your team was able to rule that out? If not, we'll try it next.
Reply With Quote
  #8   Spotlight this post!  
Unread 12-13-2018, 12:10 AM
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 19
sailorjoe will become famous soon enough
Re: New Motion Sensor

Hi, Danny. Those are good questions. We got the millisecond limit by scouring the web for information about the wpilib function. So we immediately discarded it from consideration for 50 microsecond timing delays. I'm never sure the RoboRio implements all the features of Java, so I usually just stick with the wpilib. Thus, we decided to go old-school and use a delay loop like you see in the code. However, if you're exploration of the Thread.sleep() method turns up a gem, we'd really like to know about it. When we measured the timing loops on the oscilloscope, we saw very stable timing pulses, like within a tenth of a microsecond of repeatability. I'd love to know if the overloaded version of Thread.sleep() works that well on the RIO. Looking forward to your test results. If they're good, we can update the code.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 05:15 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi