Skip to content

Commit

Permalink
Linear departure tool path modifier (#202)
Browse files Browse the repository at this point in the history
* Created linear departure tool path modifier

* Added widget for linear departure modifier widget

---------

Co-authored-by: David Spielman <davidroyspielman@gmail.com>
  • Loading branch information
marip8 and DavidSpielman authored Sep 15, 2023
1 parent db25b08 commit 3eff1fd
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 2 deletions.
2 changes: 2 additions & 0 deletions noether_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ qt5_wrap_cpp(${PROJECT_NAME}_widget_mocs
include/${PROJECT_NAME}/widgets/tool_path_modifiers/snake_organization_modifier_widget.h
include/${PROJECT_NAME}/widgets/tool_path_modifiers/standard_edge_paths_organization_modifier_widget.h
include/${PROJECT_NAME}/widgets/tool_path_modifiers/linear_approach_modifier_widget.h
include/${PROJECT_NAME}/widgets/tool_path_modifiers/linear_departure_modifier_widget.h
include/${PROJECT_NAME}/widgets/tool_path_modifiers/tool_drag_orientation_modifier_widget.h
include/${PROJECT_NAME}/widgets/tool_path_modifiers/uniform_orientation_modifier_widget.h)

Expand Down Expand Up @@ -85,6 +86,7 @@ add_library(${PROJECT_NAME} SHARED
src/widgets/tool_path_modifiers/snake_organization_modifier_widget.cpp
src/widgets/tool_path_modifiers/standard_edge_paths_organization_modifier_widget.cpp
src/widgets/tool_path_modifiers/linear_approach_modifier_widget.cpp
src/widgets/tool_path_modifiers/linear_departure_modifier_widget.cpp
src/widgets/tool_path_modifiers/tool_drag_orientation_modifier_widget.cpp
src/widgets/tool_path_modifiers/uniform_orientation_modifier_widget.cpp
${${PROJECT_NAME}_widget_mocs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LinearApproachToolPathModifierWidget : public ToolPathModifierWidget
void configure(const YAML::Node&) override;
void save(YAML::Node&) const override;

private:
protected:
Ui::LinearApproachModifier* ui_;
Ui::Vector3dEditor* vector_editor_ui_;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <noether_gui/widgets/tool_path_modifiers/linear_approach_modifier_widget.h>

namespace noether
{
class LinearDepartureToolPathModifierWidget : public LinearApproachToolPathModifierWidget
{
Q_OBJECT
public:
using LinearApproachToolPathModifierWidget::LinearApproachToolPathModifierWidget;

ToolPathModifier::ConstPtr create() const override;
};

} // namespace noether
5 changes: 5 additions & 0 deletions noether_gui/src/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <noether_gui/widgets/tool_path_modifiers/tool_drag_orientation_modifier_widget.h>
#include <noether_gui/widgets/tool_path_modifiers/uniform_orientation_modifier_widget.h>
#include <noether_gui/widgets/tool_path_modifiers/linear_approach_modifier_widget.h>
#include <noether_gui/widgets/tool_path_modifiers/linear_departure_modifier_widget.h>

#include <QWidget>
#include <QMessageBox>
Expand Down Expand Up @@ -91,6 +92,9 @@ using CircularLeadOutToolPathModifierWidgetPlugin =
using LinearApproachToolPathModifierWidgetPlugin =
WidgetPluginImpl<LinearApproachToolPathModifierWidget, ToolPathModifierWidget>;

using LinearDepartureToolPathModifierWidgetPlugin =
WidgetPluginImpl<LinearDepartureToolPathModifierWidget, ToolPathModifierWidget>;

// Raster Tool Path Planners
struct PlaneSlicerRasterPlannerWidgetPlugin : ToolPathPlannerWidgetPlugin
{
Expand Down Expand Up @@ -136,5 +140,6 @@ EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::ToolDragOrientationToolPathModi
EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::CircularLeadInToolPathModifierWidgetPlugin, CircularLeadInModifier)
EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::CircularLeadOutToolPathModifierWidgetPlugin, CircularLeadOutModifier)
EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::LinearApproachToolPathModifierWidgetPlugin, LinearApproachModifier)
EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::LinearDepartureToolPathModifierWidgetPlugin, LinearDepartureModifier)

EXPORT_TPP_WIDGET_PLUGIN(noether::PlaneSlicerRasterPlannerWidgetPlugin, PlaneSlicerRasterPlanner)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <noether_gui/widgets/tool_path_modifiers/linear_departure_modifier_widget.h>
#include <noether_gui/utils.h>

#include <noether_tpp/tool_path_modifiers/linear_departure_modifier.h>
#include "ui_vector3d_editor_widget.h"
#include "ui_linear_approach_modifier_widget.h"

namespace noether
{
ToolPathModifier::ConstPtr LinearDepartureToolPathModifierWidget::create() const
{
if (ui_->combo_box_menu->currentIndex() == 0)
{
auto axis = static_cast<LinearDepartureModifier::Axis>(ui_->combo_box_axis->currentIndex());
return std::make_unique<LinearDepartureModifier>(
ui_->double_spin_box_offset->value(), axis, ui_->spin_box_points->value());
}
else
{
Eigen::Vector3d dir(vector_editor_ui_->double_spin_box_x->value(),
vector_editor_ui_->double_spin_box_y->value(),
vector_editor_ui_->double_spin_box_z->value());
return std::make_unique<LinearDepartureModifier>(dir, ui_->spin_box_points->value());
}
}

} // namespace noether
1 change: 1 addition & 0 deletions noether_tpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ add_library(${PROJECT_NAME} SHARED
src/tool_path_modifiers/snake_organization_modifier.cpp
src/tool_path_modifiers/standard_edge_paths_organization_modifier.cpp
src/tool_path_modifiers/linear_approach_modifier.cpp
src/tool_path_modifiers/linear_departure_modifier.cpp
src/tool_path_modifiers/tool_drag_orientation_modifier.cpp
src/tool_path_modifiers/uniform_orientation_modifier.cpp
# Tool Path Planners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LinearApproachModifier : public ToolPathModifier
LinearApproachModifier(Eigen::Vector3d offset, std::size_t n_points);
LinearApproachModifier(double offset_height, Axis axis, std::size_t n_points);

ToolPaths modify(ToolPaths tool_paths) const override final;
ToolPaths modify(ToolPaths tool_paths) const override;

protected:
Eigen::Vector3d offset_;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <noether_tpp/tool_path_modifiers/linear_approach_modifier.h>

namespace noether
{
/**
* @brief Adds a series of waypoints in a linear pattern off the last waypoint in a tool path
*/
class LinearDepartureModifier : public LinearApproachModifier
{
public:
using LinearApproachModifier::LinearApproachModifier;

ToolPaths modify(ToolPaths tool_paths) const override final;
};

} // namespace noether
29 changes: 29 additions & 0 deletions noether_tpp/src/tool_path_modifiers/linear_departure_modifier.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <noether_tpp/tool_path_modifiers/linear_departure_modifier.h>

namespace noether
{
ToolPaths LinearDepartureModifier::modify(ToolPaths tool_paths) const
{
for (ToolPath& tool_path : tool_paths)
{
for (ToolPathSegment& segment : tool_path)
{
Eigen::Isometry3d offset_point = segment.back() * Eigen::Translation3d(offset_);
ToolPathSegment new_segment;

for (int i = 0; i <= n_points_; i++)
{
Eigen::Isometry3d pt;
pt = offset_point * Eigen::Translation3d(-offset_ + (offset_ / (n_points_)) * i);
pt.linear() = segment.back().linear();
new_segment.push_back(pt);
}

segment.insert(segment.end(), new_segment.rbegin(), new_segment.rend());
}
}

return tool_paths;
}

} // namespace noether

0 comments on commit 3eff1fd

Please sign in to comment.