#ifndef COMPLIB_SERVER_ROBOT_HPP
#define COMPLIB_SERVER_ROBOT_HPP

#include <cmath>

#define ROBOT_IR_SENSOR_COUNT 5
#define ROBOT_IR_RATE_HZ 250

#define ROBOT_MOTOR_COUNT 4
#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

#define ROBOT_ODOMETRY_CONTROLLER_RATE_HZ 250
#define ROBOT_ODOMETRY_CONTROLLER_LEFT_PORT 3
#define ROBOT_ODOMETRY_CONTROLLER_RIGHT_PORT 0
#define ROBOT_ODOMETRY_CONTROLLER_LEFT_MULT 1.0
#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)
#define ROBOT_WHEEL_CIRCUMFERENCE_MM (2.0 * ROBOT_WHEEL_RADIUS_MM * M_PI)
#define ROBOT_WHEEL_CIRCUMFERENCE_M (2 * ROBOT_WHEEL_RADIUS_M * M_PI)
#define ROBOT_TICKS_PER_TURN 2770.0
#define ROBOT_ARBOR_LENGTH_MM 140.0
#define ROBOT_ARBOR_LENGTH_M (ROBOT_ARBOR_LENGTH_MM / 1000.0)
#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_RATE_HZ 200
#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_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.9
#define ROBOT_GO_TO_ANGLE_MIN_VEL M_PI_2

#endif //COMPLIB_SERVER_ROBOT_HPP
