Finish drive distance, finish turn_angle

This commit is contained in:
Konstantin Lampalzer 2022-05-28 01:09:34 +02:00
parent 92d42be8b8
commit 4be754c1db
10 changed files with 249 additions and 132 deletions

View file

@ -0,0 +1,33 @@
//
// Created by KonstantinViesure on 26.05.22.
//
#ifndef COMPLIB_SERVER_GOTOCONTROLLER_HPP
#define COMPLIB_SERVER_GOTOCONTROLLER_HPP
class GoToController {
public:
static GoToController &getInstance() {
static GoToController instance;
return instance;
}
GoToController(GoToController const &) = delete;
void operator=(GoToController const &) = delete;
static void drive_distance(double distance_m, double v_ms);
static void turn_degrees(double angle_deg, double v_rad_s);
static void go_to_point(double goal_x, double goal_y, double v_ms);
static void diff_drive_inverse_kinematics(double v_m_s, double w_rad_s);
private:
GoToController() = default;
};
#endif //COMPLIB_SERVER_GOTOCONTROLLER_HPP

View file

@ -1,29 +0,0 @@
//
// Created by KonstantinViesure on 26.05.22.
//
#ifndef COMPLIB_SERVER_GOTOGOALCONTROLLER_HPP
#define COMPLIB_SERVER_GOTOGOALCONTROLLER_HPP
class GoToGoalController {
public:
static GoToGoalController &getInstance() {
static GoToGoalController instance;
return instance;
}
GoToGoalController(GoToGoalController const &) = delete;
void operator=(GoToGoalController const &) = delete;
static void go_to_point(double goal_x, double goal_y, double v_ms);
static void diff_drive_inverse_kinematics(double v_m_s, double w_rad_s);
private:
GoToGoalController() = default;
};
#endif //COMPLIB_SERVER_GOTOGOALCONTROLLER_HPP

View file

@ -3,6 +3,7 @@
#include <thread>
#include <mutex>
#include <chrono>
#include "include/Odometry.hpp"
@ -34,6 +35,7 @@ private:
OdometryController();
std::thread odometry_thread;
std::recursive_mutex odometry_mutex;
[[noreturn]] void odometry_loop();

View file

@ -7,9 +7,9 @@
#define ROBOT_IR_RATE_HZ 250
#define ROBOT_MOTOR_COUNT 4
#define ROBOT_MOTOR_SPEED_CONTROL_KP 2.5
#define ROBOT_MOTOR_SPEED_CONTROL_KI 19.0
#define ROBOT_MOTOR_SPEED_CONTROL_KD 0.07
#define ROBOT_MOTOR_SPEED_CONTROL_KP 8.5
#define ROBOT_MOTOR_SPEED_CONTROL_KI 31.0
#define ROBOT_MOTOR_SPEED_CONTROL_KD 0.085
#define ROBOT_MOTOR_SPEED_CONTROL_RAMP 4 * M_PI
#define ROBOT_MOTOR_SPEED_CONTROL_RATE_HZ 250
@ -31,5 +31,9 @@
#define ROBOT_TICKS_PER_METER (1000.0 / ROBOT_WHEEL_CIRCUMFERENCE_MM * ROBOT_TICKS_PER_TURN)
#define ROBOT_GO_TO_GOAL_K 0.99 // Between 0.5 and 1
#define ROBOT_GO_TO_DISTANCE_ALPHA_P 2.0
#define ROBOT_GO_TO_DISTANCE_VELOCITY_P 5.0
#define ROBOT_GO_TO_DISTANCE_END_M 0.01 // stop approx 1 cm before target
#define ROBOT_GO_TO_ANGLE_END_RAD (0.5 * (M_PI / 180.0)) // stop 0.5 deg before target
#endif //COMPLIB_SERVER_ROBOT_HPP