-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeEstimate.h
112 lines (90 loc) · 3.34 KB
/
timeEstimate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//Copyright (c) 2018 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef TIME_ESTIMATE_H
#define TIME_ESTIMATE_H
#include <stdint.h>
#include <vector>
#include <unordered_map>
#include "PrintFeature.h"
#include "settings/types/Duration.h" //Print time estimates.
#include "settings/types/Ratio.h" //For speed factors.
#include "settings/types/Velocity.h" //Speeds and accelerations at which we print.
namespace cura
{
class Settings;
/*!
* The TimeEstimateCalculator class generates a estimate of printing time calculated with acceleration in mind.
* Some of this code has been adapted from the Marlin sources.
*/
class TimeEstimateCalculator
{
public:
constexpr static unsigned int NUM_AXIS = 4;
constexpr static unsigned int X_AXIS = 0;
constexpr static unsigned int Y_AXIS = 1;
constexpr static unsigned int Z_AXIS = 2;
constexpr static unsigned int E_AXIS = 3;
class Position
{
public:
Position() {for(unsigned int n=0;n<NUM_AXIS;n++) axis[n] = 0;}
Position(double x, double y, double z, double e) {axis[0] = x;axis[1] = y;axis[2] = z;axis[3] = e;}
double axis[NUM_AXIS];
double& operator[](const int n) { return axis[n]; }
};
class Block
{
public:
bool recalculate_flag;
double accelerate_until;
double decelerate_after;
Velocity initial_feedrate;
Velocity final_feedrate;
Velocity entry_speed;
Velocity max_entry_speed;
bool nominal_length_flag;
Velocity nominal_feedrate;
double maxTravel;
double distance;
Acceleration acceleration;
Position delta;
Position absDelta;
PrintFeatureType feature;
};
private:
Velocity max_feedrate[NUM_AXIS] = {600, 600, 40, 25}; // mm/s
Velocity minimumfeedrate = 0.01;
Acceleration acceleration = 3000;
Acceleration max_acceleration[NUM_AXIS] = {9000, 9000, 100, 10000};
Velocity max_xy_jerk = 20.0;
Velocity max_z_jerk = 0.4;
Velocity max_e_jerk = 5.0;
Duration extra_time = 0.0;
Position previous_feedrate;
Velocity previous_nominal_feedrate;
Position currentPosition;
std::vector<Block> blocks;
public:
/*!
* \brief Set the movement configuration of the firmware.
* \param settings_base Where to get the settings from.
*/
void setFirmwareDefaults(const Settings& settings);
void setPosition(Position newPos);
void plan(Position newPos, Velocity feedRate, PrintFeatureType feature);
void addTime(const Duration& time);
void setAcceleration(const Acceleration& acc); //!< Set the default acceleration to \p acc
void setMaxXyJerk(const Velocity& jerk); //!< Set the max xy jerk to \p jerk
void setMaxZFeedrate(const Velocity& max_z_feedrate); //!< Set the maximal feedrate in the z direction to \p max_z_feedrate
void reset();
std::vector<Duration> calculate();
private:
void reverse_pass();
void forward_pass();
void recalculate_trapezoids();
void calculate_trapezoid_for_block(Block *block, const Ratio entry_factor, const Ratio exit_factor);
void planner_reverse_pass_kernel(Block *previous, Block *current, Block *next);
void planner_forward_pass_kernel(Block *previous, Block *current, Block *next);
};
}//namespace cura
#endif//TIME_ESTIMATE_H