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

Smooth manual flight #130

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions app/rdd2/src/manual.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ static void rdd2_manual_entry_point(void* p0, void* p1, void* p2)
// set normalized inputs
ctx->actuators_manual.normalized_count = 4;
ctx->actuators_manual.normalized[0] = -ctx->joy.axes[JOY_AXES_ROLL];
ctx->actuators_manual.normalized[1] = ctx->joy.axes[JOY_AXES_PITCH];
ctx->actuators_manual.normalized[2] = ctx->joy.axes[JOY_AXES_YAW];
ctx->actuators_manual.normalized[3] = ctx->joy.axes[JOY_AXES_THRUST];
ctx->actuators_manual.normalized[1] = -ctx->joy.axes[JOY_AXES_PITCH];
ctx->actuators_manual.normalized[2] = -ctx->joy.axes[JOY_AXES_YAW];
ctx->actuators_manual.normalized[3] = ctx->joy.axes[JOY_AXES_THRUST] * 0.5 + 0.5;

// saturation
for (int i = 0; i < 4; i++) {
Expand Down
2 changes: 1 addition & 1 deletion app/rdd2/src/mixing.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void rdd2_set_actuators(synapse_msgs_Actuators* msg, double roll, double pitch,
msg->header.seq++;
strncpy(msg->header.frame_id, "odom", sizeof(msg->header.frame_id) - 1);

const float k = 10;
const float k = 1600;

msg->position_count = 0;
msg->velocity_count = 4;
Expand Down
16 changes: 8 additions & 8 deletions app/rdd2/src/velocity.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ static void update_cmd_vel(context* ctx)
}
*/

double roll_rate_cmd = ctx->actuators_manual.velocity[0];
double pitch_rate_cmd = ctx->actuators_manual.velocity[1];
double yaw_rate_cmd = ctx->actuators_manual.velocity[2];
double thrust_cmd = ctx->actuators_manual.velocity[3];

double roll = 1.0 * (roll_rate_cmd - ctx->imu.angular_velocity.x);
double pitch = 1.0 * (pitch_rate_cmd - ctx->imu.angular_velocity.y);
double yaw = 1.0 * (yaw_rate_cmd - ctx->imu.angular_velocity.z);
double roll_rate_cmd = ctx->actuators_manual.normalized[0];
double pitch_rate_cmd = ctx->actuators_manual.normalized[1];
double yaw_rate_cmd = ctx->actuators_manual.normalized[2];
double thrust_cmd = ctx->actuators_manual.normalized[3];

double roll = 0.01 * (roll_rate_cmd - ctx->imu.angular_velocity.x);
double pitch = 0.01 * (pitch_rate_cmd + ctx->imu.angular_velocity.y);
double yaw = 0.05 * (yaw_rate_cmd + ctx->imu.angular_velocity.z);

rdd2_set_actuators(&ctx->actuators, roll, pitch, yaw, thrust_cmd);
}
Expand Down
Loading