Rev 2126 | Rev 2131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2126 | Rev 2129 | ||
---|---|---|---|
Line 128... | Line 128... | ||
128 | target[axis] -= OVER360; |
128 | target[axis] -= OVER360; |
129 | } else if (target[axis] <= -OVER180) { |
129 | } else if (target[axis] <= -OVER180) { |
130 | target[axis] += OVER360; |
130 | target[axis] += OVER360; |
131 | } |
131 | } |
Line 132... | Line -... | ||
132 | - | ||
133 | //if (reverse[axis]) |
- | |
134 | error[axis] = attitude[axis] - target[axis]; |
- | |
135 | // else |
132 | |
Line -... | Line 133... | ||
- | 133 | /* This is the difference limitation only way. The 2 subtrahends stay unmodified. */ |
|
- | 134 | ||
- | 135 | error[axis] = attitude[axis] - target[axis]; |
|
- | 136 | if (error[axis] > OVER180) { |
|
- | 137 | error[axis] -= OVER360; |
|
- | 138 | } else if (error[axis] <= -OVER180) { |
|
- | 139 | error[axis] += OVER360; |
|
136 | // error[axis] = attitude[axis] - target[axis]; |
140 | } |
137 | 141 | // Believe it or not, the below limiter does NOT solve the wrapping problem. Must do explicitly. |
|
138 | if (error[axis] > maxError[axis]) { |
142 | if (error[axis] > maxError[axis]) { |
139 | error[axis] = maxError[axis]; |
143 | error[axis] = maxError[axis]; |
140 | } else if (error[axis] < -maxError[axis]) { |
144 | } else if (error[axis] < -maxError[axis]) { |
141 | error[axis] =- maxError[axis]; |
145 | error[axis] = -maxError[axis]; |
- | 146 | } else { |
|
- | 147 | // update I parts here for angles mode. I parts in rate mode is something different. |
|
- | 148 | } |
|
- | 149 | ||
- | 150 | /* |
|
- | 151 | * This is the beginning of a version that adjusts the target to differ from the attitude |
|
- | 152 | * by a limited amount. This will eliminate memory over large errors but also knock target angles. |
|
- | 153 | * Idea: The limit could be calculated from the max. servo deflection divided by I factor... |
|
- | 154 | * |
|
- | 155 | */ |
|
- | 156 | /* |
|
- | 157 | if(abs(attitude[axis]-target[axis]) > OVER180) { |
|
- | 158 | if(target[axis] > attitude[axis]) { |
|
142 | } else { |
159 | |
- | 160 | } |
|
Line 143... | Line 161... | ||
143 | // update I parts here for angles mode. Ĩ parts in rate mode is something different. |
161 | } |
144 | } |
162 | */ |
145 | 163 | ||
146 | /************************************************************************/ |
164 | /************************************************************************/ |