-
Notifications
You must be signed in to change notification settings - Fork 5
Base Control
This node is in charge of processing the velocity commands, converts linear/angular velocitys into movement commands and is in charge of executing them (hardware control). And also it is responsible of processing all motor encoders ticks and publish them in a ros topic to process odometry in another node.
All movement commands are implemented with a PID (proportional – integral – derivative) controller, in order to maintain the desired velocity and direction in the best possible way, regardless of any disturbances the robot may have while moving.
According to the velocity commands (m/s) received, every motor has a target revolutions per second velocity. Each motor has its PID controller in order to constantly been changing its pwm value, always trying to mantain the input close the setpoint.
void Motor::constantSpeed(const double velocity) {
double new_pwm_value = pwm_;
pid_.compute(
// Setpoint //Input //Output 0-255
MsToRps(velocity), getActualRps(), new_pwm_value,
);
changePwm(new_pwm_value);
}
This node receives a delta tick count from the encoder of each motor and computes all odometer data. The node processes the time it is passing to be as accurate as possible.
//compute the velocities of each wheel
double v_w1 = (wheel1_new * dist_per_tick)/dt_front;
double v_w2 = (wheel2_new * dist_per_tick)/dt_back;
double v_w3 = (wheel3_new * dist_per_tick)/dt_back;
double v_w4 = (wheel4_new * dist_per_tick)/dt_front;
//compute the overall velocity of the robot
vx = (wheel_radius/4)*(v_w1+v_w2+v_w3+v_w4);
vy = (wheel_radius/4)*(v_w1-v_w2-v_w3+v_w4);
vth = (wheel_radius/(4*k))*(-v_w1+v_w2-v_w3+v_w4);
//compute the change in displacement
double delta_x = vx * avg_dt;
double delta_y = vy * avg_dt;
double delta_th = vth * avg_dt;
//compute the overall displacement
x = x + delta_x;
y = y + delta_y;
th = th + delta_th;
Model capable to simulate the robot behavior of the base_control
module in Rviz.
Running:
- Map Sever
- Odometry calculator node.
- Velocity commands simulation node.
- Rviz simulation node.
This launch runs an extra node called encoders_simulation, simulating ticks of the encoders of the robot, the rviz simulation responds according to the ticks simulation.
roslaunch src/navigation/base_control/launch/test/odometry_rviz.launch
This launch runs an extra node that established serial communication with the Microcontroller, the rviz simulation responds according to the robot movements.
roslaunch src/navigation/base_control/launch/base_control.launch