scanse / sweep-sdk

Sweep SDK
MIT License
90 stars 85 forks source link

Sensor protocol description nitpicking #89

Closed MikeGitb closed 7 years ago

MikeGitb commented 7 years ago

The protocol description file e.g. says

Azimuth: Angle that ranging was recorded at (in degrees). Azimuth is a float value, transmitted as a 16 bit int. This needs to be converted from 16bit int to float. Use instructions in the Appendix. Note: the lower order byte is received first, higher order byte is received second.

I'm not sure if this is just confusing or even wrong, but in any case wouldn't it be simpler to say something like:

Azimuth: Angle that ranging was recorded at (in degrees). Azimuth is transmitted as a 16 bit fixed point value with a scaling factor of 16 (4bit after radix) in little endian format (first byte is low order).

Also the conversion from wire format to storage format seems to be unnecessarily complicated. Wouldn't a simple

static_cast<int>(angle/16.0 * 1000.0) 

do the trick? Or have I overlooked something?

dcyoung commented 7 years ago

I like the simplification a lot! That could help clear up a fair amount of confusion. I'll check with @kent-williams to see if there is any edge case or reason why we're using the more complicated formula. Otherwise I'll whip this up into a PR now.