remove unsupported touchprobe module, has been archived in branch archive/touchprobe
[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
11 #include <vector>
12 #include <bitset>
13 #include "ActuatorCoordinates.h"
14
15 class Gcode;
16
17 class Block {
18 public:
19 Block();
20 void calculate_trapezoid( float entry_speed, float exit_speed );
21 float estimate_acceleration_distance( float initial_rate, float target_rate, float acceleration );
22 float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance);
23 float max_allowable_speed( float acceleration, float target_velocity, float distance);
24
25 float reverse_pass(float exit_speed);
26 float forward_pass(float next_entry_speed);
27
28 float max_exit_speed();
29
30 void debug();
31
32 void append_gcode(Gcode* gcode);
33
34 void take();
35 void release();
36
37 void ready();
38
39 void clear();
40
41 void begin();
42
43 std::vector<Gcode> gcodes;
44
45 std::array<uint32_t, k_max_actuators> steps; // Number of steps for each axis for this block
46 uint32_t steps_event_count; // Steps for the longest axis
47 uint32_t nominal_rate; // Nominal rate in steps per second
48 float nominal_speed; // Nominal speed in mm per second
49 float millimeters; // Distance for this move
50 float entry_speed;
51 float exit_speed;
52 float rate_delta; // Number of steps to add to the speed for each acceleration tick
53 float acceleration; // the acceleratoin for this block
54 uint32_t initial_rate; // Initial speed in steps per second
55 uint32_t final_rate; // Final speed in steps per second
56 uint32_t accelerate_until; // Stop accelerating after this number of steps
57 uint32_t decelerate_after; // Start decelerating after this number of steps
58
59 float max_entry_speed;
60
61 int16_t 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.
62
63 std::bitset<k_max_actuators> direction_bits; // Direction for each axis in bit form, relative to the direction port's mask
64 struct {
65 bool recalculate_flag:1; // Planner flag to recalculate trapezoids on entry junction
66 bool nominal_length_flag:1; // Planner flag for nominal speed always reached
67 bool is_ready:1;
68 };
69 };
70
71
72 #endif