Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Addressed the comments
  • Loading branch information
tmldeponti committed Mar 12, 2024
1 parent 793b165 commit 07d7deb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions conf/airframes/tudelft/rot_wing_v3b.xml
Expand Up @@ -41,8 +41,8 @@
</module>

<module name="wing_rotation_adc_sensor">
<define name="ADC_SCALE" value="0.00247111"/>
<define name="ADC_OFFSET" value="-25.635294"/>
<define name="ADC_WING_ROT_SCALE" value="0.00247111"/>
<define name="ADC_WING_ROT_OFFSET" value="-25.635294"/>
</module>

<!-- <module name="mavlink">
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/modules/rot_wing_drone/rotwing_state.c
Expand Up @@ -157,7 +157,7 @@ inline void guidance_indi_hybrid_set_wls_settings(float body_v[3], float roll_an
static void send_rotating_wing_state(struct transport_tx *trans, struct link_device *dev)
{
#if ADC_WING_ROTATION
uint16_t adc_dummy = adc_wing_rotation_extern;
uint16_t adc_dummy = skew_adc_sensor;
#else
uint16_t adc_dummy = 0;
#endif
Expand Down
22 changes: 11 additions & 11 deletions sw/airborne/modules/rot_wing_drone/wing_rotation_adc_sensor.c
Expand Up @@ -39,38 +39,38 @@
#define ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION_NB_SAMPLES 16
#endif

#ifndef ADC_OFFSET
#error "ADC_OFFSET not defined"
#ifndef ADC_WING_ROT_OFFSET
#error "ADC_WING_ROT_OFFSET not defined"
#endif

#ifndef ADC_SCALE
#error "ADC_SCALE not defined"
#ifndef ADC_WING_ROT_SCALE
#error "ADC_WING_ROT_SCALE not defined"
#endif

#ifdef ADC_OFFSET
float adc_offset = ADC_OFFSET;
#ifdef ADC_WING_ROT_OFFSET
static float adc_offset = ADC_WING_ROT_OFFSET;
#endif

#ifdef ADC_SCALE
float adc_scale = ADC_SCALE;
#ifdef ADC_WING_ROT_SCALE
static float adc_scale = ADC_WING_ROT_SCALE;
#endif

static struct adc_buf buf_wing_rot_pos;
float adc_wing_rotation_extern;
float skew_adc_sensor;
// Initialization
void wing_rotation_adc_init(void)
{
// ADC init
adc_buf_channel(ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION, &buf_wing_rot_pos,
ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION_NB_SAMPLES);
adc_wing_rotation_extern = 0;
skew_adc_sensor = 0;
}

void wing_rotation_adc_to_deg(void)
{
float adc_wing_rotation = buf_wing_rot_pos.sum / buf_wing_rot_pos.av_nb_sample;
float wing_angle_deg = adc_scale * adc_wing_rotation + adc_offset;
adc_wing_rotation_extern = adc_wing_rotation;
skew_adc_sensor = adc_wing_rotation;

// SEND ABI Message to ctr_eff_sched and other modules that want Actuator position feedback
struct act_feedback_t feedback = {0};
Expand Down
Expand Up @@ -26,7 +26,7 @@
#ifndef WING_ROTATION_ADC_SENSOR_H
#define WING_ROTATION_ADC_SENSOR_H

extern float adc_wing_rotation_extern;
extern float skew_adc_sensor;
extern void wing_rotation_adc_init(void);
extern void wing_rotation_adc_to_deg(void);

Expand Down

0 comments on commit 07d7deb

Please sign in to comment.