Commit 0755d81c authored by Nathan Girard's avatar Nathan Girard
Browse files

cleaning code and add robot_type choice

parent 46ab8d3f
Subproject commit 645a1cb8acfd878204b39c235c8b83d428769da5 Subproject commit 7403263cea17cde4e7126222ead68d24b9255acf
...@@ -471,7 +471,7 @@ ...@@ -471,7 +471,7 @@
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>20</FileNumber> <FileNumber>20</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\BSP\Device\motor.c</PathWithFileName> <PathWithFileName>..\BSP\Device\motor.c</PathWithFileName>
......
...@@ -157,76 +157,23 @@ int main(void) ...@@ -157,76 +157,23 @@ int main(void)
/* USER CODE END WHILE */ /* USER CODE END WHILE */
/* USER CODE BEGIN 3 */ /* USER CODE BEGIN 3 */
/* scan is key be pressed down to change target speed and pwm pulse */
if (key_scan())
{
m3508_frontleft.target += 500;
m3508_frontright.target += 500;
m3508_backleft.target += 500;
m3508_backright.target += 500;
if (m3508_frontleft.target > 2000)
{
m3508_frontleft.target = 0;
m3508_frontright.target = 0;
m3508_backleft.target = 0;
m3508_backright.target = 0;
}
// PWM_SetAllDuty(&htim1, 0.1f, 0.1f, 0.1f, 0.1f);
// HAL_Delay(2500);
// PWM_SetAllDuty(&htim1, 0, 0, 0, 0);
}
if (rc_ctrl.rc.sw[0] == 2) /******************************************************************/
{ /* PENSER A CHANGER LE TYPE DE ROBOT SI BESOIN */
m2006.target = 0; /* (aller dans motor.h et changer ROBOT_TYPE) */
}; /******************************************************************/
if (rc_ctrl.rc.sw[0] == 3)
{
m2006.target = 2000;
};
if (rc_ctrl.rc.sw[0] == 1)
{
m2006.target = 5000;
};
if (rc_ctrl.rc.sw[1] == 2) /* scan if key is pressed down */
{ if (key_scan())
PWM_SetAllDuty(&htim1, 0.0f, 0.0f, 0.0f, 0.0f);
};
if (rc_ctrl.rc.sw[1] == 3)
{
PWM_SetAllDuty(&htim1, 0.25f, 0.25f, 0.25f, 0.25f);
};
if (rc_ctrl.rc.sw[1] == 1)
{ {
PWM_SetAllDuty(&htim1, 0.5f, 0.5f, 0.5f, 0.5f); /* put here the actions you want to do when key is pressed */
}; }
m3508_frontleft.target = MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] + rc_ctrl.rc.ch[1] - rc_ctrl.rc.ch[4]);
m3508_frontright.target = -MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] - rc_ctrl.rc.ch[1] + rc_ctrl.rc.ch[4]);
m3508_backright.target = -MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] + rc_ctrl.rc.ch[1] + rc_ctrl.rc.ch[4]);
m3508_backleft.target = MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] - rc_ctrl.rc.ch[1] - rc_ctrl.rc.ch[4]);
gm6020_down.target = gm6020_down.target - rc_ctrl.rc.ch[3]*0.1;
gm6020_up.target = gm6020_up.target - rc_ctrl.rc.ch[2]*0.1;
if (gm6020_down.target > gm6020_down.MAX_POSITION){gm6020_down.target = gm6020_down.MAX_POSITION;} /* Setting the target for all motors according to the data received from the remote controler */
if (gm6020_down.target < gm6020_down.MIN_POSITION){gm6020_down.target = gm6020_down.MIN_POSITION;} set_all_targets_from_rc();
if (gm6020_up.target > gm6020_up.MAX_POSITION){gm6020_up.target = gm6020_up.MAX_POSITION;}
if (gm6020_up.target < gm6020_up.MIN_POSITION){gm6020_up.target = gm6020_up.MIN_POSITION;}
/* Command all motors according to the target fixed */
get_motor_data(&m3508_frontleft); command_all_motors();
get_motor_data(&m3508_frontright);
get_motor_data(&m3508_backleft);
get_motor_data(&m3508_backright);
get_motor_data(&m2006);
get_motor_data(&gm6020_up);
get_motor_data(&gm6020_down);
/*Affichage de donnees sur le OLED*/ /*Affichage de donnees sur le OLED*/
oled_clear(Pen_Clear); oled_clear(Pen_Clear);
...@@ -235,14 +182,6 @@ int main(void) ...@@ -235,14 +182,6 @@ int main(void)
oled_printf(3, 1," Speed: %i", gm6020_up.info.GM6020_info.angle); oled_printf(3, 1," Speed: %i", gm6020_up.info.GM6020_info.angle);
oled_printf(4, 1," Angle: %i", gm6020_down.info.GM6020_info.angle); oled_printf(4, 1," Angle: %i", gm6020_down.info.GM6020_info.angle);
oled_refresh_gram(); oled_refresh_gram();
// oled_clear(Pen_Clear);
// oled_printf(0, 1, "Manette");
// oled_printf(1, 1," CH1: %i", rc_ctrl.rc.ch[0]);
// oled_printf(2, 1," CH2: %i", rc_ctrl.rc.ch[1]);
// oled_printf(3, 1," CH3: %i", rc_ctrl.rc.ch[2]);
// oled_printf(4, 1," CH4: %i", rc_ctrl.rc.ch[3]);
// oled_refresh_gram();
/* led blink */ /* led blink */
led_cnt ++; led_cnt ++;
...@@ -252,17 +191,6 @@ int main(void) ...@@ -252,17 +191,6 @@ int main(void)
LED_RED_TOGGLE(); //blink cycle 500ms LED_RED_TOGGLE(); //blink cycle 500ms
} }
set_motor_speed(&m3508_frontleft);
set_motor_speed(&m3508_frontright);
set_motor_speed(&m3508_backleft);
set_motor_speed(&m3508_backright);
set_motor_speed(&m2006);
set_motor_position(&gm6020_up);
set_motor_position(&gm6020_down);
set_motor_voltage(0, &m3508_frontleft, &m3508_frontright, &m3508_backright, &m3508_backleft); //0x200
set_motor_voltage(1, &gm6020_up, &gm6020_down, &m2006, NULL); //0x1ff
HAL_Delay(10); HAL_Delay(10);
} }
/* USER CODE END 3 */ /* USER CODE END 3 */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment