Skip to content

Commit d21a6bf

Browse files
committed
Smooth manual flight to be used with the fox-glove-joy bluetooth controller support.
Signed-off-by: Chase Hamdan <chamdan@purdue.edu>
1 parent 51086b8 commit d21a6bf

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

app/rdd2/src/manual.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ static void rdd2_manual_entry_point(void* p0, void* p1, void* p2)
8080
// set normalized inputs
8181
ctx->actuators_manual.normalized_count = 4;
8282
ctx->actuators_manual.normalized[0] = -ctx->joy.axes[JOY_AXES_ROLL];
83-
ctx->actuators_manual.normalized[1] = ctx->joy.axes[JOY_AXES_PITCH];
84-
ctx->actuators_manual.normalized[2] = ctx->joy.axes[JOY_AXES_YAW];
85-
ctx->actuators_manual.normalized[3] = ctx->joy.axes[JOY_AXES_THRUST];
83+
ctx->actuators_manual.normalized[1] = -ctx->joy.axes[JOY_AXES_PITCH];
84+
ctx->actuators_manual.normalized[2] = -ctx->joy.axes[JOY_AXES_YAW];
85+
ctx->actuators_manual.normalized[3] = ctx->joy.axes[JOY_AXES_THRUST]*0.5 + 0.5;
8686

8787
// saturation
8888
for (int i = 0; i < 4; i++) {

app/rdd2/src/mixing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void rdd2_set_actuators(synapse_msgs_Actuators* msg, double roll, double pitch,
1212
msg->header.seq++;
1313
strncpy(msg->header.frame_id, "odom", sizeof(msg->header.frame_id) - 1);
1414

15-
const float k = 10;
15+
const float k = 1600;
1616

1717
msg->position_count = 0;
1818
msg->velocity_count = 4;

app/rdd2/src/velocity.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ static void update_cmd_vel(context* ctx)
8282
}
8383
*/
8484

85-
double roll_rate_cmd = ctx->actuators_manual.velocity[0];
86-
double pitch_rate_cmd = ctx->actuators_manual.velocity[1];
87-
double yaw_rate_cmd = ctx->actuators_manual.velocity[2];
88-
double thrust_cmd = ctx->actuators_manual.velocity[3];
89-
90-
double roll = 1.0 * (roll_rate_cmd - ctx->imu.angular_velocity.x);
91-
double pitch = 1.0 * (pitch_rate_cmd - ctx->imu.angular_velocity.y);
92-
double yaw = 1.0 * (yaw_rate_cmd - ctx->imu.angular_velocity.z);
85+
double roll_rate_cmd = ctx->actuators_manual.normalized[0];
86+
double pitch_rate_cmd = ctx->actuators_manual.normalized[1];
87+
double yaw_rate_cmd = ctx->actuators_manual.normalized[2];
88+
double thrust_cmd = ctx->actuators_manual.normalized[3];
89+
90+
double roll = 0.01 * (roll_rate_cmd - ctx->imu.angular_velocity.x);
91+
double pitch = 0.01 * (pitch_rate_cmd + ctx->imu.angular_velocity.y);
92+
double yaw = 0.05 * (yaw_rate_cmd + ctx->imu.angular_velocity.z);
9393

9494
rdd2_set_actuators(&ctx->actuators, roll, pitch, yaw, thrust_cmd);
9595
}

0 commit comments

Comments
 (0)