robot code for summer school
Dependencies: PM2_Libary Eigen
Fork of PM2_Example_Summer_School by
Diff: Robot_Library/robot.h
- Revision:
- 76:2302f2b51e63
- Parent:
- 74:76c7a805f63d
- Child:
- 77:19cf9072bc22
--- a/Robot_Library/robot.h Mon May 30 20:21:15 2022 +0200 +++ b/Robot_Library/robot.h Tue May 31 10:44:16 2022 +0200 @@ -20,8 +20,8 @@ INITIAL, IDLE, FOLLOWING_LINE, - RIGHT_TURN_90, - LEFT_TURN_90, + RIGHT_TURN, + LEFT_TURN, AVOIDING_OBSTACLE, }; @@ -31,8 +31,8 @@ void Initial(); void Idle(); void FollowingLine(); // takes in rotational velocity? - void LeftTurn_90(); - void RightTurn_90(); + void LeftTurn(); + void RightTurn(); void AvoidObstacle(); //PID @@ -41,9 +41,9 @@ void PID_Delay(int ms); bool IsSharpTurn(int b); - const float k_prop = 3.0f; - const float k_int = 1.5f; - const float k_deriv = 0.0f; + const float k_prop = 2.5f; + const float k_int = 1.25f; + const float k_deriv = 1.0f; float previous_error_value; float integral_error; @@ -51,7 +51,8 @@ /* CONSTANTS */ const float DISTANCE_THRESHOLD = 0.2f; // minimum allowed distance to obstacle in [m] - const float TRANSLATIONAL_VELOCITY = 0.12f; // translational velocity in [m/s] + const float TRANSLATIONAL_VELOCITY = 0.15f; // translational velocity in [m/s] + const float ROTATIONAL_VELOCITY = 1.2f; // rotational velocity in [rad/s] const float VELOCITY_THRESHOLD = 0.05; // velocity threshold before switching off, in [m/s] and [rad/s] const float WHEEL_RADIUS = 0.0306f; @@ -91,6 +92,10 @@ Eigen::Vector2f wheel_speed_smooth; // Wheel speeds limited and smoothed Eigen::Vector2f wheel_speed_actual; // Measured wheel speeds Eigen::Vector2f robot_speed_actual; // Measured robot speed + + // tracking + float theta; + float target_theta; }; #endif \ No newline at end of file