Skip to content

Commit

Permalink
crazyflie: fix PWM channel ordering
Browse files Browse the repository at this point in the history
Channels belonging to a certain timer were not all grouped together.
This is required by the .first_channel_index and .last_channel_index data
members.

We introduce a new mixer geometry to solve the problem.
  • Loading branch information
bkueng authored and davids5 committed Feb 13, 2020
1 parent 17ab617 commit 73bd90d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ROMFS/px4fmu_common/init.d/airframes/4900_crazyflie
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
sh /etc/init.d/rc.mc_defaults

set MIXER quad_x
set MIXER quad_x_cw
set PWM_OUT 1234
if [ $AUTOCNF = yes ]
then
Expand Down
1 change: 1 addition & 0 deletions ROMFS/px4fmu_common/mixers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ px4_add_romfs_files(
quad_+_vtol.main.mix
quad_w.main.mix
quad_x.main.mix
quad_x_cw.main.mix
quad_x_vtol.main.mix
stampede.main.mix
tri_y_yaw-.main.mix
Expand Down
5 changes: 5 additions & 0 deletions ROMFS/px4fmu_common/mixers/quad_x_cw.main.mix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @board px4_fmu-v2 exclude
# Quad X with clock-wise motor assigment

R: 4xcw 10000 10000 10000 0

18 changes: 9 additions & 9 deletions boards/bitcraze/crazyflie/src/timer_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ __EXPORT const timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = {
.ccr_offset = STM32_GTIM_CCR2_OFFSET,
.masks = GTIM_SR_CC2IF | GTIM_SR_CC2OF
},
{
// M2
.gpio_out = GPIO_TIM2_CH4OUT,
.gpio_in = GPIO_TIM2_CH4IN,
.timer_index = 0,
.timer_channel = 4,
.ccr_offset = STM32_GTIM_CCR4_OFFSET,
.masks = GTIM_SR_CC4IF | GTIM_SR_CC4OF
},
{
// M3
.gpio_out = GPIO_TIM2_CH1OUT,
Expand All @@ -110,13 +119,4 @@ __EXPORT const timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = {
.ccr_offset = STM32_GTIM_CCR4_OFFSET,
.masks = GTIM_SR_CC4IF | GTIM_SR_CC4OF
},
{
// M2
.gpio_out = GPIO_TIM2_CH4OUT,
.gpio_in = GPIO_TIM2_CH4IN,
.timer_index = 0,
.timer_channel = 4,
.ccr_offset = STM32_GTIM_CCR4_OFFSET,
.masks = GTIM_SR_CC4IF | GTIM_SR_CC4OF
},
};
1 change: 1 addition & 0 deletions src/lib/mixer/MultirotorMixer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ set(geometry_files
quad_s250aq.toml
quad_vtail.toml
quad_wide.toml
quad_x_cw.toml
quad_x.toml
quad_x_pusher.toml
quad_y.toml
Expand Down
30 changes: 30 additions & 0 deletions src/lib/mixer/MultirotorMixer/geometries/quad_x_cw.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generic Quadcopter in X configuration
# with clock-wise motor numbering

[info]
key = "4xcw"
description = "Quadcopter in X configuration with clock-wise motor numbering"

[rotor_default]
direction = "CW"
axis = [0.0, 0.0, -1.0]
Ct = 1.0
Cm = 0.05

[[rotors]]
name = "front_right"
position = [0.707107, 0.707107, 0.0]
direction = "CCW"

[[rotors]]
name = "rear_right"
position = [-0.707107, 0.707107, 0.0]

[[rotors]]
name = "rear_left"
position = [-0.707107, -0.707107, 0.0]
direction = "CCW"

[[rotors]]
name = "front_left"
position = [0.707107, -0.707107, 0.0]

0 comments on commit 73bd90d

Please sign in to comment.