Fix large bit shifts when processing scan
This commit is contained in:
@@ -48,8 +48,8 @@ func processScan(raw: Data) throws -> LidarScan {
|
||||
if (raw[1] & 0b1) != 1 {
|
||||
throw RPLidarError.SCAN_ERROR(message: "Check bit not equal to 1")
|
||||
}
|
||||
let angle = (Float(raw[1] >> 1) + Float(raw[2] << 7)) / 64
|
||||
let distance = (Float(raw[3]) + Float(raw[4] << 8)) / 4
|
||||
let angle = Float((Int(raw[1]) >> 1) + (Int(raw[2]) << 7)) / 64
|
||||
let distance = Float(Int(raw[3]) + (Int(raw[4]) << 8)) / 4
|
||||
return LidarScan(newScan: newScan == 1, quality: quality, angle: angle, distance: distance)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user