162{
163 Vec2d position = initial_xy;
164 bool absolute = true;
165 bool coordinate_frame_known = true;
166
170 absolute = true;
171 return;
172 }
174 absolute = false;
175 return;
176 }
177
179 if (is_motion) {
181 position.x() = absolute ? line.
x() : position.x() + line.
x();
183 position.y() = absolute ? line.
y() : position.y() + line.
y();
184 return;
185 }
186
187
188
189
191 coordinate_frame_known = coordinate_frame_known && !line.
has_x() && !line.
has_y();
192 }
else if (line.
cmd_is(
"G28")) {
193 const bool homes_all = !line.
has_x() && !line.
has_y() && !line.
has_z();
194 coordinate_frame_known = coordinate_frame_known && !homes_all && !line.
has_x() && !line.
has_y();
195 }
196 });
197
198 return coordinate_frame_known ? std::optional<Vec2d>(position) : std::nullopt;
199}
Definition GCodeReader.hpp:21
float x() const
Definition GCodeReader.hpp:76
bool has_z() const
Definition GCodeReader.hpp:67
float y() const
Definition GCodeReader.hpp:77
bool has_y() const
Definition GCodeReader.hpp:66
bool has_x() const
Definition GCodeReader.hpp:65
bool cmd_is(const char *cmd_test) const
Definition GCodeReader.hpp:58
Definition GCodeReader.hpp:19
void parse_buffer(const std::string &buffer, Callback callback)
Definition GCodeReader.hpp:119
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67