first commit
[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 "mbed.h"
14 #include "libs/Module.h"
15 #include "libs/Kernel.h"
16 #include "../communication/utils/Gcode.h"
17 #include "arm_solutions/BaseSolution.h"
18 #include "Planner.h"
19
20 #define default_seek_rate_checksum 6633
21 #define default_feed_rate_checksum 47357
22 #define mm_per_line_segment_checksum 30176
23 #define mm_per_arc_segment_checksum 15470
24
25 #define NEXT_ACTION_DEFAULT 0
26 #define NEXT_ACTION_DWELL 1
27 #define NEXT_ACTION_GO_HOME 2
28
29 #define MOTION_MODE_SEEK 0 // G0
30 #define MOTION_MODE_LINEAR 1 // G1
31 #define MOTION_MODE_CW_ARC 2 // G2
32 #define MOTION_MODE_CCW_ARC 3 // G3
33 #define MOTION_MODE_CANCEL 4 // G80
34
35 #define PATH_CONTROL_MODE_EXACT_PATH 0
36 #define PATH_CONTROL_MODE_EXACT_STOP 1
37 #define PATH_CONTROL_MODE_CONTINOUS 2
38
39 #define PROGRAM_FLOW_RUNNING 0
40 #define PROGRAM_FLOW_PAUSED 1
41 #define PROGRAM_FLOW_COMPLETED 2
42
43 #define SPINDLE_DIRECTION_CW 0
44 #define SPINDLE_DIRECTION_CCW 1
45
46
47
48 class Robot : public Module {
49 public:
50 Robot();
51 void on_module_loaded();
52 void on_gcode_received(void* argument);
53 void execute_gcode(Gcode* gcode);
54 void append_milestone( double target[], double feed_rate);
55 void append_line( double target[], double feed_rate);
56 void append_arc(double theta_start, double angular_travel, double radius, double depth, double rate);
57 void compute_arc(double offset[], double target[]);
58 double to_millimeters(double value);
59 double theta(double x, double y);
60 void select_plane(uint8_t axis_0, uint8_t axis_1, uint8_t axis_2);
61
62 double current_position[3]; // Current position, in millimeters
63 double last_milestone[3]; // Last position, in millimeters
64 bool inch_mode; // true for inch mode, false for millimeter mode ( default )
65 bool absolute_mode; // true for absolute mode ( default ), false for relative mode
66 uint8_t motion_mode; // Motion mode for the current received Gcode
67 double seek_rate; // Current rate for seeking moves ( mm/s )
68 double feed_rate; // Current rate for feeding moves ( mm/s )
69 uint8_t plane_axis_0, plane_axis_1, plane_axis_2; // Current plane ( XY, XZ, YZ )
70 BaseSolution* arm_solution; // Selected Arm solution ( millimeters to step calculation )
71 double mm_per_line_segment; // Setting : Used to split lines into segments
72 double mm_per_arc_segment; // Setting : Used to split arcs into segments
73 };
74
75 #endif