Skip to content

Commit

Permalink
Try to kepp motors quiet on zero velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
Divelix committed May 17, 2021
1 parent 592544e commit 983d920
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/SerialTransceiver/SerialTransceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ void SerialTransceiver::rx()
calcChecksum = crc8((uint8_t *)controlVec, 3);
if (readChecksum == calcChecksum)
{
(*desiredVelocity)(0) = mapUint8ToFloat(controlVec[0], -maxAngSpeed, maxAngSpeed);
(*desiredVelocity)(1) = mapUint8ToFloat(controlVec[1], -maxLinSpeed, maxLinSpeed);
(*desiredVelocity)(2) = mapUint8ToFloat(controlVec[2], -maxLinSpeed, maxLinSpeed);
if (controlVec[0] == controlVec[1] == controlVec[2] == 127)
{
(*desiredVelocity)(0) = 0.0;
(*desiredVelocity)(1) = 0.0;
(*desiredVelocity)(2) = 0.0;
}
else
{
(*desiredVelocity)(0) = mapUint8ToFloat(controlVec[0], -maxAngSpeed, maxAngSpeed);
(*desiredVelocity)(1) = mapUint8ToFloat(controlVec[1], -maxLinSpeed, maxLinSpeed);
(*desiredVelocity)(2) = mapUint8ToFloat(controlVec[2], -maxLinSpeed, maxLinSpeed);
}
// memcpy(desiredVelocity, vec, 12);
}
}
Expand Down

0 comments on commit 983d920

Please sign in to comment.