fixed bug with planner/stepper interaction
[clinton/Smoothieware.git] / src / modules / robot / Planner.h
CommitLineData
4cff3ded
AW
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 PLANNER_H
9#define PLANNER_H
10
11#include <vector>
12#include "libs/RingBuffer.h"
13#include "../communication/utils/Gcode.h"
14#include "Block.h"
15
16#define acceleration_checksum 25326
17#define max_jerk_checksum 61012
18
aab6cbba
AW
19// TODO: Get from config
20#define MINIMUM_PLANNER_SPEED 0.0
4cff3ded
AW
21using namespace std;
22
aab6cbba
AW
23
24
25
26
4cff3ded
AW
27class Planner : public Module {
28 public:
29 Planner();
aab6cbba
AW
30 void append_block( int target[], double feed_rate, double distance, double deltas[] );
31 double max_allowable_speed( double acceleration, double target_velocity, double distance);
4cff3ded
AW
32 void attach_gcode_to_queue(Gcode* gcode);
33 void recalculate();
34 void reverse_pass();
35 void forward_pass();
36 void recalculate_trapezoids();
37 void dump_queue();
38 Block* get_current_block();
39 void discard_current_block();
40 void cleanup_queue();
41 void on_module_loaded();
da24d6ae 42 void on_config_reload(void* argument);
4cff3ded
AW
43
44 int position[3]; // Current position, in steps
aab6cbba 45 double previous_unit_vec[3];
a1b7e9f0 46 RingBuffer<Block,64> queue; // Queue of Blocks
4cff3ded
AW
47 bool computing; // Whether or not we are currently computing the queue, TODO: Checks if this is necessary
48 Block last_deleted_block; // Item -1 in the queue, TODO: Grbl does not need this, but Smoothie won't work without it, we are probably doing something wrong
49 bool has_deleted_block; // Flag for above value
aab6cbba 50 float previous_nominal_speed;
4cff3ded
AW
51
52 double acceleration; // Setting
53 double max_jerk; // Setting
54
55};
56
57
58
59#endif