Skip to content
This repository was archived by the owner on Feb 25, 2021. It is now read-only.

Commit 1d8eaa6

Browse files
author
Johannes Formann
committed
changed to 50hz to reduce cpu util
1 parent 9b8e65f commit 1d8eaa6

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/autosteer.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ AutoPID pid(
4545

4646
constexpr time_t Timeout = 2000;
4747

48-
void autosteerWorker100Hz( void* z ) {
49-
constexpr TickType_t xFrequency = 10;
48+
void autosteerWorker( void* z ) {
49+
constexpr TickType_t xFrequency = 20;
5050
TickType_t xLastWakeTime = xTaskGetTickCount();
5151

5252
pid.setTimeStep( xFrequency );
@@ -80,7 +80,7 @@ void autosteerWorker100Hz( void* z ) {
8080

8181
static uint8_t loopCounter = 0;
8282

83-
if ( ++loopCounter >= 10 ) {
83+
if ( ++loopCounter >= 5 ) {
8484
loopCounter = 0;
8585

8686
//close enough to center, 4 cm, remove any correction
@@ -235,7 +235,7 @@ if ( driveValue < 0 ) {
235235
{
236236
static uint8_t loopCounter = 0;
237237

238-
if ( ++loopCounter >= 10 ) {
238+
if ( ++loopCounter >= 5 ) {
239239
loopCounter = 0;
240240

241241
if ( initialisation.outputType != SteerConfig::OutputType::None ) {
@@ -654,5 +654,5 @@ void initAutosteer() {
654654

655655
}
656656

657-
xTaskCreate( autosteerWorker100Hz, "autosteerWorker", 4096, NULL, 3, NULL );
657+
xTaskCreate( autosteerWorker, "autosteerWorker", 4096, NULL, 3, NULL );
658658
}

src/sensor.cpp

+15-13
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,18 @@ class FilterBuLp2_3 {
9898
v[1] = 0.0;
9999
}
100100
private:
101-
float v[3];
102-
public:
103-
float step( float x ) { //class II
104-
v[0] = v[1];
105-
v[1] = v[2];
106-
v[2] = ( 2.008336556421122521e-2 * x )
107-
+ ( -0.64135153805756306422 * v[0] )
108-
+ ( 1.56101807580071816339 * v[1] );
109-
return
110-
( v[0] + v[2] )
111-
+ 2 * v[1];
112-
}
101+
float v[3];
102+
public:
103+
float step(float x) { //class II
104+
v[0] = v[1];
105+
v[1] = v[2];
106+
v[2] = (6.745527388907189559e-2 * x)
107+
+ (-0.41280159809618854894 * v[0])
108+
+ (1.14298050253990091107 * v[1]);
109+
return
110+
(v[0] + v[2])
111+
+2 * v[1];
112+
}
113113
} wheelAngleSensorFilter;
114114

115115
void genericImuCalibrationCalcMagnetometer() {
@@ -451,7 +451,7 @@ void updateImuData(float gx, float gy, float gz, float ax, float ay, float az, f
451451

452452
void sensorWorkerSteeringPoller( void* z ) {
453453
vTaskDelay( 2000 );
454-
constexpr TickType_t xFrequency = 10;
454+
constexpr TickType_t xFrequency = 20;
455455
TickType_t xLastWakeTime = xTaskGetTickCount();
456456

457457
for ( ;; ) {
@@ -504,6 +504,8 @@ void sensorWorkerSteeringPoller( void* z ) {
504504

505505
steerSetpoints.wheelAngleRaw = wheelAngleTmp;
506506

507+
// now zero position and counts per degre of the sensor is nown (raw value)
508+
507509
if ( steerConfig.wheelAngleSensorType == SteerConfig::WheelAngleSensorType::TieRodDisplacement ) {
508510
if ( steerConfig.wheelAngleFirstArmLenght != 0 && steerConfig.wheelAngleSecondArmLenght != 0 &&
509511
steerConfig.wheelAngleTrackArmLenght != 0 && steerConfig.wheelAngleTieRodStroke != 0 ) {

0 commit comments

Comments
 (0)