removed most mbed.h includes
[clinton/Smoothieware.git] / src / modules / robot / Robot.h
1 /*
2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
6 */
7
8 #ifndef ROBOT_H
9 #define ROBOT_H
10
11 #include <string>
12 using std::string;
13 #include "libs/Module.h"
14 #include "libs/Kernel.h"
15 #include "../communication/utils/Gcode.h"
16 #include "arm_solutions/BaseSolution.h"
17 #include "Planner.h"
18
19 #define default_seek_rate_checksum 6633
20 #define default_feed_rate_checksum 47357
21 #define mm_per_line_segment_checksum 30176
22 #define mm_per_arc_segment_checksum 15470
23 #define arc_correction_checksum 5074
24 #define x_axis_max_speed_checksum 64935
25 #define y_axis_max_speed_checksum 3752
26 #define z_axis_max_speed_checksum 7849
27
28 #define NEXT_ACTION_DEFAULT 0
29 #define NEXT_ACTION_DWELL 1
30 #define NEXT_ACTION_GO_HOME 2
31
32 #define MOTION_MODE_SEEK 0 // G0
33 #define MOTION_MODE_LINEAR 1 // G1
34 #define MOTION_MODE_CW_ARC 2 // G2
35 #define MOTION_MODE_CCW_ARC 3 // G3
36 #define MOTION_MODE_CANCEL 4 // G80
37
38 #define PATH_CONTROL_MODE_EXACT_PATH 0
39 #define PATH_CONTROL_MODE_EXACT_STOP 1
40 #define PATH_CONTROL_MODE_CONTINOUS 2
41
42 #define PROGRAM_FLOW_RUNNING 0
43 #define PROGRAM_FLOW_PAUSED 1
44 #define PROGRAM_FLOW_COMPLETED 2
45
46 #define SPINDLE_DIRECTION_CW 0
47 #define SPINDLE_DIRECTION_CCW 1
48
49
50
51 class Robot : public Module {
52 public:
53 Robot();
54 void on_module_loaded();
55 void on_config_reload(void* argument);
56 void on_gcode_received(void* argument);
57 void execute_gcode(Gcode* gcode);
58 void append_milestone( double target[], double feed_rate);
59 void append_line( Gcode* gcode, double target[], double feed_rate);
60 //void append_arc(double theta_start, double angular_travel, double radius, double depth, double rate);
61 void append_arc( Gcode* gcode, double target[], double offset[], double radius, bool is_clockwise );
62
63
64 void compute_arc(Gcode* gcode, double offset[], double target[]);
65 double to_millimeters(double value);
66 double theta(double x, double y);
67 void select_plane(uint8_t axis_0, uint8_t axis_1, uint8_t axis_2);
68
69 double current_position[3]; // Current position, in millimeters
70 double last_milestone[3]; // Last position, in millimeters
71 bool inch_mode; // true for inch mode, false for millimeter mode ( default )
72 bool absolute_mode; // true for absolute mode ( default ), false for relative mode
73 uint8_t motion_mode; // Motion mode for the current received Gcode
74 double seek_rate; // Current rate for seeking moves ( mm/s )
75 double feed_rate; // Current rate for feeding moves ( mm/s )
76 uint8_t plane_axis_0, plane_axis_1, plane_axis_2; // Current plane ( XY, XZ, YZ )
77 BaseSolution* arm_solution; // Selected Arm solution ( millimeters to step calculation )
78 double mm_per_line_segment; // Setting : Used to split lines into segments
79 double mm_per_arc_segment; // Setting : Used to split arcs into segmentrs
80
81 // Number of arc generation iterations by small angle approximation before exact arc trajectory
82 // correction. This parameter maybe decreased if there are issues with the accuracy of the arc
83 // generations. In general, the default value is more than enough for the intended CNC applications
84 // of grbl, and should be on the order or greater than the size of the buffer to help with the
85 // computational efficiency of generating arcs.
86 int arc_correction; // Setting : how often to rectify arc computation
87 double max_speeds[3]; // Setting : max allowable speed in mm/m for each axis
88
89 };
90
91 #endif