Add movement class to python
This commit is contained in:
parent
2c5f283a46
commit
d4c49a0a51
18 changed files with 240 additions and 53 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
#include "include/PID.hpp"
|
||||
#include "include/Robot.hpp"
|
||||
|
@ -46,6 +47,7 @@ private:
|
|||
std::array<double, ROBOT_MOTOR_COUNT> speed_targets{0};
|
||||
|
||||
std::thread speed_control_thread;
|
||||
std::recursive_mutex speed_control_mutex;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -21,14 +21,18 @@ public:
|
|||
|
||||
std::array<double, ROBOT_MOTOR_COUNT> get_velocities_rad_s();
|
||||
|
||||
std::array<double, ROBOT_MOTOR_COUNT> get_velocities_ticks_s();
|
||||
|
||||
private:
|
||||
Encoders() = default;
|
||||
|
||||
Cache position_cache{ROBOT_ENCODER_RATE_HZ};
|
||||
Cache velocity_cache{ROBOT_ENCODER_RATE_HZ};
|
||||
Cache ticks_cache{ROBOT_ENCODER_RATE_HZ};
|
||||
|
||||
std::array<int32_t, ROBOT_MOTOR_COUNT> cached_positions = {0};
|
||||
std::array<double, ROBOT_MOTOR_COUNT> cached_velocities_rad_s = {0};
|
||||
std::array<double, ROBOT_MOTOR_COUNT> cached_velocities_ticks_s = {0};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#define ROBOT_IR_RATE_HZ 250
|
||||
|
||||
#define ROBOT_MOTOR_COUNT 4
|
||||
#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_KP 15.0
|
||||
#define ROBOT_MOTOR_SPEED_CONTROL_KI 5.0
|
||||
#define ROBOT_MOTOR_SPEED_CONTROL_KD 0.0
|
||||
#define ROBOT_MOTOR_SPEED_CONTROL_RAMP 4 * M_PI
|
||||
#define ROBOT_MOTOR_SPEED_CONTROL_RATE_HZ 250
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
|||
#define ROBOT_ODOMETRY_CONTROLLER_RIGHT_MULT -1.0
|
||||
|
||||
#define ROBOT_ENCODER_RATE_HZ 500
|
||||
#define ROBOT_ENCODER_MAX_CHANGE_RAD_S M_PI_4
|
||||
|
||||
#define ROBOT_WHEEL_RADIUS_MM 35.5
|
||||
#define ROBOT_WHEEL_RADIUS_M (ROBOT_WHEEL_RADIUS_MM / 1000.0)
|
||||
|
@ -34,13 +35,13 @@
|
|||
|
||||
#define ROBOT_GO_TO_DISTANCE_RATE_HZ 200
|
||||
#define ROBOT_GO_TO_DISTANCE_ALPHA_P 2.0
|
||||
#define ROBOT_GO_TO_DISTANCE_VELOCITY_P 10.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_DISTANCE_MIN_VEL 0.075
|
||||
|
||||
#define ROBOT_GO_TO_ANGLE_RATE_HZ 200
|
||||
#define ROBOT_GO_TO_ANGLE_END_RAD (0.5 * (M_PI / 180.0)) // stop 0.5 deg before target
|
||||
#define ROBOT_GO_TO_ANGLE_ALPHA_P 0.5
|
||||
#define ROBOT_GO_TO_ANGLE_MIN_VEL (M_PI / 2.0)
|
||||
#define ROBOT_GO_TO_ANGLE_ALPHA_P 0.9
|
||||
#define ROBOT_GO_TO_ANGLE_MIN_VEL M_PI_2
|
||||
|
||||
#endif //COMPLIB_SERVER_ROBOT_HPP
|
||||
|
|
Reference in a new issue