Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Mavic gyro variables to velocity #5927

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions projects/robots/dji/mavic/controllers/mavic2pro/mavic2pro.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ int main(int argc, char **argv) {
const double roll = wb_inertial_unit_get_roll_pitch_yaw(imu)[0];
const double pitch = wb_inertial_unit_get_roll_pitch_yaw(imu)[1];
const double altitude = wb_gps_get_values(gps)[2];
const double roll_acceleration = wb_gyro_get_values(gyro)[0];
const double pitch_acceleration = wb_gyro_get_values(gyro)[1];
const double roll_velocity = wb_gyro_get_values(gyro)[0];
const double pitch_velocity = wb_gyro_get_values(gyro)[1];

// Blink the front LEDs alternatively with a 1 second rate.
const bool led_state = ((int)time) % 2;
wb_led_set(front_left_led, led_state);
wb_led_set(front_right_led, !led_state);

// Stabilize the Camera by actuating the camera motors according to the gyro feedback.
wb_motor_set_position(camera_roll_motor, -0.115 * roll_acceleration);
wb_motor_set_position(camera_pitch_motor, -0.1 * pitch_acceleration);
wb_motor_set_position(camera_roll_motor, -0.115 * roll_velocity);
wb_motor_set_position(camera_pitch_motor, -0.1 * pitch_velocity);

// Transform the keyboard input to disturbances on the stabilization algorithm.
double roll_disturbance = 0.0;
Expand Down Expand Up @@ -163,8 +163,8 @@ int main(int argc, char **argv) {
}

// Compute the roll, pitch, yaw and vertical inputs.
const double roll_input = k_roll_p * CLAMP(roll, -1.0, 1.0) + roll_acceleration + roll_disturbance;
const double pitch_input = k_pitch_p * CLAMP(pitch, -1.0, 1.0) + pitch_acceleration + pitch_disturbance;
const double roll_input = k_roll_p * CLAMP(roll, -1.0, 1.0) + roll_velocity + roll_disturbance;
const double pitch_input = k_pitch_p * CLAMP(pitch, -1.0, 1.0) + pitch_velocity + pitch_disturbance;
const double yaw_input = yaw_disturbance;
const double clamped_difference_altitude = CLAMP(target_altitude - altitude + k_vertical_offset, -1.0, 1.0);
const double vertical_input = k_vertical_p * pow(clamped_difference_altitude, 3.0);
Expand Down