Allow TABS in config
[clinton/Smoothieware.git] / src / modules / robot / Block.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 BLOCK_H
9 #define BLOCK_H
10 #include "libs/Module.h"
11 #include "libs/Kernel.h"
12 #include "Gcode.h"
13
14 using namespace std;
15 #include <string>
16 #include <vector>
17
18
19
20 float max_allowable_speed( float acceleration, float target_velocity, float distance);
21
22 class Block {
23 public:
24 Block();
25 void calculate_trapezoid( float entry_speed, float exit_speed );
26 float estimate_acceleration_distance( float initial_rate, float target_rate, float acceleration );
27 float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance);
28 float get_duration_left(unsigned int already_taken_steps);
29
30 float reverse_pass(float exit_speed);
31 float forward_pass(float next_entry_speed);
32
33 float max_exit_speed();
34
35 void debug();
36
37 void append_gcode(Gcode* gcode);
38
39 void take();
40 void release();
41
42 void ready();
43
44 void clear();
45
46 void begin();
47
48 //vector<std::string> commands;
49 //vector<float> travel_distances;
50 vector<Gcode> gcodes;
51
52 unsigned int steps[3]; // Number of steps for each axis for this block
53 unsigned int steps_event_count; // Steps for the longest axis
54 unsigned int nominal_rate; // Nominal rate in steps per second
55 float nominal_speed; // Nominal speed in mm per second
56 float millimeters; // Distance for this move
57 float entry_speed;
58 float exit_speed;
59 float rate_delta; // Nomber of steps to add to the speed for each acceleration tick
60 unsigned int initial_rate; // Initial speed in steps per second
61 unsigned int final_rate; // Final speed in steps per second
62 unsigned int accelerate_until; // Stop accelerating after this number of steps
63 unsigned int decelerate_after; // Start decelerating after this number of steps
64 unsigned int direction_bits; // Direction for each axis in bit form, relative to the direction port's mask
65
66
67 bool recalculate_flag; // Planner flag to recalculate trapezoids on entry junction
68 bool nominal_length_flag; // Planner flag for nominal speed always reached
69
70 float max_entry_speed;
71
72 bool is_ready;
73
74 short times_taken; // A block can be "taken" by any number of modules, and the next block is not moved to until all the modules have "released" it. This value serves as a tracker.
75
76 };
77
78
79 #endif