disable compensation transform for the G38 probes
authorJim Morris <morris@wolfman.com>
Sat, 20 Feb 2016 05:22:17 +0000 (21:22 -0800)
committerJim Morris <morris@wolfman.com>
Sat, 20 Feb 2016 05:22:17 +0000 (21:22 -0800)
fix what homing saves in the last probe position

src/modules/tools/endstops/Endstops.cpp
src/modules/tools/zprobe/ZProbe.cpp

index b6123a0..ee04db3 100644 (file)
@@ -680,6 +680,13 @@ void Endstops::on_gcode_received(void *argument)
             }
         }
 
+        // save current actuator position so we can report how far we moved
+        ActuatorCoordinates start_pos{
+            THEKERNEL->robot->actuators[X_AXIS]->get_current_position(),
+            THEKERNEL->robot->actuators[Y_AXIS]->get_current_position(),
+            THEKERNEL->robot->actuators[Z_AXIS]->get_current_position()
+        };
+
         // Enable the motors
         THEKERNEL->stepper->turn_enable_pins_on();
 
@@ -711,7 +718,12 @@ void Endstops::on_gcode_received(void *argument)
         }
 
         // set the last probe position to the actuator units moved during this home
-        THEKERNEL->robot->set_last_probe_position(std::make_tuple(STEPPER[0]->get_stepped()/STEPS_PER_MM(0), STEPPER[1]->get_stepped()/STEPS_PER_MM(1), STEPPER[2]->get_stepped()/STEPS_PER_MM(2), 0));
+        THEKERNEL->robot->set_last_probe_position(
+            std::make_tuple(
+                start_pos[0]-THEKERNEL->robot->actuators[0]->get_current_position(),
+                start_pos[1]-THEKERNEL->robot->actuators[1]->get_current_position(),
+                start_pos[2]-THEKERNEL->robot->actuators[2]->get_current_position(),
+                0));
 
         if(home_all) {
             // Here's where we would have been if the endstops were perfectly trimmed
index 6d07181..4661a08 100644 (file)
@@ -364,6 +364,10 @@ void ZProbe::on_gcode_received(void *argument)
         // first wait for an empty queue i.e. no moves left
         THEKERNEL->conveyor->wait_for_empty_queue();
 
+        // turn off any compensation transform
+        auto savect= THEKERNEL->robot->compensationTransform;
+        THEKERNEL->robot->compensationTransform= nullptr;
+
         if(gcode->has_letter('X')) {
             // probe in the X axis
             probe_XY(gcode, X_AXIS);
@@ -414,6 +418,10 @@ void ZProbe::on_gcode_received(void *argument)
             gcode->stream->printf("error:at least one of X Y or Z must be specified\n");
 
         }
+
+        // restore compensationTransform
+        THEKERNEL->robot->compensationTransform= savect;
+
         return;
 
     } else if(gcode->has_m) {