Browse Source

Merge pull request #3783 from thinkyhead/rc_bezier_delta_fix

Bezier style and DELTA patch
Scott Lahteine 8 years ago
parent
commit
82c2d308dc
1 changed files with 22 additions and 13 deletions
  1. 22
    13
      Marlin/planner_bezier.cpp

+ 22
- 13
Marlin/planner_bezier.cpp View File

113
   float second1 = target[Y_AXIS] + offset[3];
113
   float second1 = target[Y_AXIS] + offset[3];
114
   float t = 0.0;
114
   float t = 0.0;
115
 
115
 
116
-  float tmp[4];
117
-  tmp[X_AXIS] = position[X_AXIS];
118
-  tmp[Y_AXIS] = position[Y_AXIS];
116
+  float bez_target[4];
117
+  bez_target[X_AXIS] = position[X_AXIS];
118
+  bez_target[Y_AXIS] = position[Y_AXIS];
119
   float step = MAX_STEP;
119
   float step = MAX_STEP;
120
 
120
 
121
   uint8_t idle_counter = 0;
121
   uint8_t idle_counter = 0;
141
       float candidate_t = 0.5 * (t + new_t);
141
       float candidate_t = 0.5 * (t + new_t);
142
       float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
142
       float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
143
       float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
143
       float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
144
-      float interp_pos0 = 0.5 * (tmp[X_AXIS] + new_pos0);
145
-      float interp_pos1 = 0.5 * (tmp[Y_AXIS] + new_pos1);
144
+      float interp_pos0 = 0.5 * (bez_target[X_AXIS] + new_pos0);
145
+      float interp_pos1 = 0.5 * (bez_target[Y_AXIS] + new_pos1);
146
       if (dist1(candidate_pos0, candidate_pos1, interp_pos0, interp_pos1) <= (SIGMA)) break;
146
       if (dist1(candidate_pos0, candidate_pos1, interp_pos0, interp_pos1) <= (SIGMA)) break;
147
       new_t = candidate_t;
147
       new_t = candidate_t;
148
       new_pos0 = candidate_pos0;
148
       new_pos0 = candidate_pos0;
157
       if (candidate_t >= 1.0) break;
157
       if (candidate_t >= 1.0) break;
158
       float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
158
       float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
159
       float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
159
       float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
160
-      float interp_pos0 = 0.5 * (tmp[X_AXIS] + candidate_pos0);
161
-      float interp_pos1 = 0.5 * (tmp[Y_AXIS] + candidate_pos1);
160
+      float interp_pos0 = 0.5 * (bez_target[X_AXIS] + candidate_pos0);
161
+      float interp_pos1 = 0.5 * (bez_target[Y_AXIS] + candidate_pos1);
162
       if (dist1(new_pos0, new_pos1, interp_pos0, interp_pos1) > (SIGMA)) break;
162
       if (dist1(new_pos0, new_pos1, interp_pos0, interp_pos1) > (SIGMA)) break;
163
       new_t = candidate_t;
163
       new_t = candidate_t;
164
       new_pos0 = candidate_pos0;
164
       new_pos0 = candidate_pos0;
180
     t = new_t;
180
     t = new_t;
181
 
181
 
182
     // Compute and send new position
182
     // Compute and send new position
183
-    tmp[X_AXIS] = new_pos0;
184
-    tmp[Y_AXIS] = new_pos1;
183
+    bez_target[X_AXIS] = new_pos0;
184
+    bez_target[Y_AXIS] = new_pos1;
185
     // FIXME. The following two are wrong, since the parameter t is
185
     // FIXME. The following two are wrong, since the parameter t is
186
     // not linear in the distance.
186
     // not linear in the distance.
187
-    tmp[Z_AXIS] = interp(position[Z_AXIS], target[Z_AXIS], t);
188
-    tmp[E_AXIS] = interp(position[E_AXIS], target[E_AXIS], t);
189
-    clamp_to_software_endstops(tmp);
190
-    planner.buffer_line(tmp[X_AXIS], tmp[Y_AXIS], tmp[Z_AXIS], tmp[E_AXIS], feed_rate, extruder);
187
+    bez_target[Z_AXIS] = interp(position[Z_AXIS], target[Z_AXIS], t);
188
+    bez_target[E_AXIS] = interp(position[E_AXIS], target[E_AXIS], t);
189
+    clamp_to_software_endstops(bez_target);
190
+
191
+    #if ENABLED(DELTA) || ENABLED(SCARA)
192
+      calculate_delta(bez_target);
193
+      #if ENABLED(AUTO_BED_LEVELING_FEATURE)
194
+        adjust_delta(bez_target);
195
+      #endif
196
+      planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], bez_target[E_AXIS], feed_rate, extruder);
197
+    #else
198
+      planner.buffer_line(bez_target[X_AXIS], bez_target[Y_AXIS], bez_target[Z_AXIS], bez_target[E_AXIS], feed_rate, extruder);
199
+    #endif
191
   }
200
   }
192
 }
201
 }
193
 
202
 

Loading…
Cancel
Save