Skip to content

Commit

Permalink
debug the control forward and back
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbearishappy committed Nov 6, 2017
1 parent bac5a3b commit 33e728b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions sourcecode/source_code/APP/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ int32_t PID_Cal_Speed(pid_s *p, int32_t current,int32_t target,unsigned char whi
{
int32_t temp;
//target = 1;
current = current + 0;//target speed is 0
//if(target == 1)current += 1;
//else if(target == 2) current -= 1;
if(target == 1)current += 2.2;
else if(target == 2) current -= 2.2;
temp = (int32_t)(current);
spd_v = spd_v * 4 / 5 + (float)(current) / 5;

Expand All @@ -80,25 +79,29 @@ int32_t PID_Cal_Speed(pid_s *p, int32_t current,int32_t target,unsigned char whi
else if(RIGHT_WHEEL == which_wheel)
spd_length_r+= (int32_t)temp;
}

#define TEMP1 3
if(LEFT_WHEEL == which_wheel){
if(target == 1)
if(target == 1){
spd_length_l += ADD_VALUE_FB;
else if(target == 2)
if(spd_length_l > TEMP1) spd_length_l = TEMP1;
}else if(target == 2){
spd_length_l -= ADD_VALUE_FB;
else if(target == 3)
if(spd_length_l < -TEMP1) spd_length_l = -TEMP1;
}else if(target == 3)
spd_length_l += ADD_VALUE_LR;
else if(target == 4)
spd_length_l -= ADD_VALUE_LR;

spd_length = spd_length_l;
}
else if(RIGHT_WHEEL == which_wheel){
if(target == 1)
if(target == 1){
spd_length_r += ADD_VALUE_FB;
else if(target == 2)
if(spd_length_r > TEMP1) spd_length_r = TEMP1;
}else if(target == 2){
spd_length_r -= ADD_VALUE_FB;
else if(target == 3)
if(spd_length_r < -TEMP1) spd_length_r = -TEMP1;
}else if(target == 3)
spd_length_r -= ADD_VALUE_LR;
else if(target == 4)
spd_length_r += ADD_VALUE_LR;
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/source_code/APP/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define RIGHT_WHEEL 0x52//'R' 's ascii code is 0x52

#define ADD_VALUE_LR 0.4
#define ADD_VALUE_FB 1
#define ADD_VALUE_FB 0.1//1

typedef struct PID
{
Expand Down

0 comments on commit 33e728b

Please sign in to comment.