interp_inverse.cc
1 /******************************************************************** 2 * Description: interp_inverse.cc 3 * 4 * Derived from a work by Thomas Kramer 5 * 6 * Author: 7 * License: GPL Version 2 8 * System: Linux 9 * 10 * Copyright (c) 2004 All rights reserved. 11 * 12 * Last change: 13 ********************************************************************/ 14 #include <unistd.h> 15 #include <stdio.h> 16 #include <stdlib.h> 17 #include <math.h> 18 #include <string.h> 19 #include <ctype.h> 20 #include <sys/types.h> 21 #include <sys/stat.h> 22 #include "rs274ngc.hh" 23 #include "interp_return.hh" 24 #include "interp_internal.hh" 25 #include "interp_queue.hh" 26 #include "rs274ngc_interp.hh" 27 28 /****************************************************************************/ 29 30 /*! inverse_time_rate_arc 31 32 Returned Value: int (INTERP_OK) 33 34 Side effects: a call is made to SET_FEED_RATE and _setup.feed_rate is set. 35 36 Called by: 37 convert_arc2 38 convert_arc_comp1 39 convert_arc_comp2 40 41 This finds the feed rate needed by an inverse time move. The move 42 consists of an a single arc. Most of the work here is in finding the 43 length of the arc. 44 45 */ 46 47 int Interp::inverse_time_rate_arc(double x1, //!< x coord of start point of arc 48 double y1, //!< y coord of start point of arc 49 double z1, //!< z coord of start point of arc 50 double cx, //!< x coord of center of arc 51 double cy, //!< y coord of center of arc 52 int turn, //!< turn of arc 53 double x2, //!< x coord of end point of arc 54 double y2, //!< y coord of end point of arc 55 double z2, //!< z coord of end point of arc 56 block_pointer block, //!< pointer to a block of RS274 instructions 57 setup_pointer settings) //!< pointer to machine settings 58 { 59 double length; 60 double rate; 61 62 if (settings->feed_mode != INVERSE_TIME) return -1; 63 64 length = find_arc_length(x1, y1, z1, cx, cy, turn, x2, y2, z2); 65 rate = std::max(0.1, (length * block->f_number)); 66 enqueue_SET_FEED_RATE(rate); 67 settings->feed_rate = rate; 68 69 return INTERP_OK; 70 } 71 72 /****************************************************************************/ 73 74 /*! inverse_time_rate_straight 75 76 Returned Value: int (INTERP_OK) 77 78 Side effects: a call is made to SET_FEED_RATE and _setup.feed_rate is set. 79 80 Called by: 81 convert_straight 82 convert_straight_comp1 83 convert_straight_comp2 84 85 This finds the feed rate needed by an inverse time straight move. Most 86 of the work here is in finding the length of the line. 87 88 */ 89 90 int Interp::inverse_time_rate_straight(double end_x, //!< x coordinate of end point of straight line 91 double end_y, //!< y coordinate of end point of straight line 92 double end_z, //!< z coordinate of end point of straight line 93 double AA_end, //!< A coordinate of end point of straight line/*AA*/ 94 double BB_end, //!< B coordinate of end point of straight line/*BB*/ 95 double CC_end, //!< C coordinate of end point of straight line/*CC*/ 96 double u_end, double v_end, double w_end, 97 block_pointer block, //!< pointer to a block of RS274 instructions 98 setup_pointer settings) //!< pointer to machine settings 99 { 100 double length; 101 double rate; 102 double cx, cy, cz; 103 104 if (settings->feed_mode != INVERSE_TIME) return -1; 105 106 if (settings->cutter_comp_side && settings->cutter_comp_radius > 0.0 && 107 !settings->cutter_comp_firstmove) { 108 cx = settings->program_x; 109 cy = settings->program_y; 110 cz = settings->program_z; 111 } else { 112 cx = settings->current_x; 113 cy = settings->current_y; 114 cz = settings->current_z; 115 } 116 117 length = find_straight_length(end_x, end_y, end_z, 118 AA_end, BB_end, CC_end, 119 u_end, v_end, w_end, 120 cx, cy, cz, 121 settings->AA_current, settings->BB_current, settings->CC_current, 122 settings->u_current, settings->v_current, settings->w_current); 123 124 rate = std::max(0.1, (length * block->f_number)); 125 enqueue_SET_FEED_RATE(rate); 126 settings->feed_rate = rate; 127 128 return INTERP_OK; 129 }