Skip to content

Commit

Permalink
Add limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
teleportina committed Mar 28, 2024
1 parent b14f911 commit 576bea0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 9 additions & 1 deletion lib/Car/Car.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Car::Car(
float ilw = 1.0 / lw;
Jac = {-lw, 1, -1, lw, 1, 1, lw, 1, -1, -lw, 1, 1};
Jac /= wheelRadius;
invJac = {ilw, -ilw, -ilw, ilw,-1, -1, -1, -1, 1, -1, 1, -1};
invJac = {-ilw, ilw, ilw, -ilw, 1, 1, 1, 1, -1, 1, -1, 1};
invJac *= wheelRadius / 4;

resetOdom();
Expand Down Expand Up @@ -69,6 +69,14 @@ void Car::setMotorsPWM(Matrix<WHEELS_COUNT, 1, float> &motorsPWM)

void Car::reachCarVelocity(Matrix<3,1, float> &carVel)
{
if(abs(carVel(0))>0.75){
carVel(0) = copysignf(0.5, carVel(0));
}
for(uint8_t i = 1; i<3; i++){
if(abs(carVel(i))>0.5){
carVel(i) = copysignf(0.5, carVel(i));
}
}
*jointVelocities = Jac * carVel;
reachWheelsAngularVelocity(*jointVelocities);
}
Expand Down
3 changes: 0 additions & 3 deletions lib/SerialTransceiver/SerialTransceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
SerialTransceiver::SerialTransceiver(Matrix<3> *desiredVelocity, Matrix<4> *jointAngles, Matrix<4> *jointVelocities)
:desiredVelocity(desiredVelocity), jointAngles(jointAngles), jointVelocities(jointVelocities)
{
maxAngSpeed = 5;
maxLinSpeed = 0.85;
threshold = 0.0001;

bufferOutSize = (jointVelocities->Rows+jointAngles->Rows)*sizeof(float)+2;
stateVector = new float[jointVelocities->Rows+jointAngles->Rows]();
Expand Down
4 changes: 0 additions & 4 deletions lib/SerialTransceiver/SerialTransceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ using namespace BLA;
class SerialTransceiver
{
private:
float maxLinSpeed;
float maxAngSpeed;
float threshold;
float fi, x, y;

Matrix<3> *desiredVelocity;
Matrix<4> *jointAngles;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include "tests/carClassTest.h"
#include "tests/finalSystem.h"

0 comments on commit 576bea0

Please sign in to comment.