Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a flat plane tool path planner #213

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions noether_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ qt5_wrap_cpp(${PROJECT_NAME}_widget_mocs
include/${PROJECT_NAME}/widgets/configurable_tpp_pipeline_widget.h
include/${PROJECT_NAME}/widgets/tpp_widget.h
# Tool Path Planners
include/${PROJECT_NAME}/widgets/tool_path_planners/flat_plane_toolpath_planner_widget.h
# Raster
# Direction Generator
include/${PROJECT_NAME}/widgets/tool_path_planners/raster/direction_generators/fixed_direction_generator_widget.h
Expand All @@ -49,6 +50,8 @@ qt5_wrap_cpp(${PROJECT_NAME}_widget_mocs

qt5_wrap_ui(${PROJECT_NAME}_widget_ui_mocs
ui/vector3d_editor_widget.ui
ui/isometry3d_editor_widget.ui
ui/vector2d_editor_widget.ui
ui/plugin_loader_widget.ui
ui/linear_approach_modifier_widget.ui
ui/raster_planner_widget.ui
Expand All @@ -66,6 +69,7 @@ add_library(${PROJECT_NAME} SHARED
src/widgets/configurable_tpp_pipeline_widget.cpp
src/widgets/tpp_widget.cpp
# Tool Path Planners
src/widgets/tool_path_planners/flat_plane_toolpath_planner_widget.cpp
# Raster Planner
src/widgets/tool_path_planners/raster/raster_planner_widget.cpp
# Direction Generator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <noether_gui/widgets.h>
#include <noether_tpp/core/tool_path_planner.h>

class QSpinBox;

namespace Ui
{
class Isometry3dEditor;
}

namespace Ui
{
class Vector2dEditor;
}

namespace noether
{
class FlatPlaneToolPathPlannerWidget : public ToolPathPlannerWidget
{
Q_OBJECT
public:
FlatPlaneToolPathPlannerWidget(QWidget* parent = nullptr);

ToolPathPlanner::ConstPtr create() const override;

void configure(const YAML::Node&) override;
void save(YAML::Node&) const override;

private:
Ui::Isometry3dEditor* origin_ui_;
Ui::Vector2dEditor* plane_dim_ui_;
Ui::Vector2dEditor* spacing_dim_ui_;
};

} // namespace noether
5 changes: 5 additions & 0 deletions noether_gui/src/plugins.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <noether_gui/plugin_interface.h>
// Tool path planners
#include <noether_gui/widgets/tool_path_planners/flat_plane_toolpath_planner_widget.h>
// Raster
#include <noether_gui/widgets/tool_path_planners/raster/raster_planner_widget.h>
// Direction Generators
Expand Down Expand Up @@ -45,6 +46,8 @@ struct WidgetPluginImpl : WidgetPlugin<BaseT>
return widget;
}
};
// Tool Path Planners
using FlatPlaneToolPathPlannerWidgetPlugin = WidgetPluginImpl<FlatPlaneToolPathPlannerWidget, ToolPathPlannerWidget>;

// Direction Generators
using FixedDirectionGeneratorWidgetPlugin =
Expand Down Expand Up @@ -142,4 +145,6 @@ EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::CircularLeadOutToolPathModifier
EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::LinearApproachToolPathModifierWidgetPlugin, LinearApproachModifier)
EXPORT_TOOL_PATH_MODIFIER_WIDGET_PLUGIN(noether::LinearDepartureToolPathModifierWidgetPlugin, LinearDepartureModifier)

EXPORT_TPP_WIDGET_PLUGIN(noether::FlatPlaneToolPathPlannerWidgetPlugin, FlatPlaneToolPathPlanner)

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

#include <noether_tpp/tool_path_planners/flat_plane_toolpath_planner.h>
#include <QFormLayout>
#include <QLabel>
#include <QDoubleSpinBox>
#include "ui_vector2d_editor_widget.h"
#include "ui_isometry3d_editor_widget.h"

static const std::string ORIGIN_PX_KEY = "px";
static const std::string ORIGIN_PY_KEY = "py";
static const std::string ORIGIN_PZ_KEY = "pz";
static const std::string ORIGIN_QX_KEY = "qx";
static const std::string ORIGIN_QY_KEY = "qy";
static const std::string ORIGIN_QZ_KEY = "qz";
static const std::string ORIGIN_QW_KEY = "qw";

static const std::string PLANE_X_DIM_KEY = "plane_x_dim";
static const std::string PLANE_Y_DIM_KEY = "plane_y_dim";
static const std::string X_SPACING_KEY = "x_spacing";
static const std::string Y_SPACING_KEY = "y_spacing";

namespace noether
{
FlatPlaneToolPathPlannerWidget::FlatPlaneToolPathPlannerWidget(QWidget* parent)
: ToolPathPlannerWidget(parent)
, origin_ui_(new Ui::Isometry3dEditor())
, plane_dim_ui_(new Ui::Vector2dEditor())
, spacing_dim_ui_(new Ui::Vector2dEditor())
{
// Create a vertical layout for the entire widget
auto mainLayout = new QVBoxLayout(this);

origin_ui_->setupUi(this);
origin_ui_->group_box->setTitle("Offset (position in meters, rotation in radians)");

plane_dim_ui_->setupUi(this);
plane_dim_ui_->group_box->setTitle("Plane Dimensions (m)");

spacing_dim_ui_->setupUi(this);
spacing_dim_ui_->group_box->setTitle("Plane Spacing (m)");

// Create a container widget to hold the layouts
auto containerWidget = new QWidget;

// Create a layout for the container widget
auto containerLayout = new QVBoxLayout(containerWidget);

// Create a horizontal layout for the spin box and label
auto spinBoxLayout = new QHBoxLayout;

// Add the horizontal layout to the container layout
containerLayout->addLayout(spinBoxLayout);

// Set the container widget as the layout for the Isometry3dEditor and Vector2dEditor widgets
origin_ui_->group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
containerLayout->addWidget(origin_ui_->group_box);

plane_dim_ui_->group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
containerLayout->addWidget(plane_dim_ui_->group_box);

spacing_dim_ui_->group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
containerLayout->addWidget(spacing_dim_ui_->group_box);

// Add the container widget to the main layout
mainLayout->addWidget(containerWidget);

// Set the main layout for the entire widget
setLayout(mainLayout);
}

ToolPathPlanner::ConstPtr FlatPlaneToolPathPlannerWidget::create() const
{
Eigen::Isometry3d origin = Eigen::Isometry3d::Identity();
// Create a quaternion from roll, pitch, yaw
Eigen::Quaterniond q(origin_ui_->double_spin_box_qw->value(),
origin_ui_->double_spin_box_qx->value(),
origin_ui_->double_spin_box_qy->value(),
origin_ui_->double_spin_box_qz->value());

// Set the translation
origin.translation() = Eigen::Vector3d(origin_ui_->double_spin_box_px->value(),
origin_ui_->double_spin_box_py->value(),
origin_ui_->double_spin_box_pz->value());

// Set the rotation
origin.rotate(q);

Eigen::Vector2d plane_dim(plane_dim_ui_->double_spin_box_x->value(), plane_dim_ui_->double_spin_box_y->value());
Eigen::Vector2d spacing(spacing_dim_ui_->double_spin_box_x->value(), spacing_dim_ui_->double_spin_box_y->value());
return std::make_unique<FlatPlaneToolPathPlanner>(plane_dim, spacing, origin);
}

void FlatPlaneToolPathPlannerWidget::configure(const YAML::Node& config)
{
origin_ui_->double_spin_box_px->setValue(getEntry<double>(config, ORIGIN_PX_KEY));
origin_ui_->double_spin_box_py->setValue(getEntry<double>(config, ORIGIN_PY_KEY));
origin_ui_->double_spin_box_pz->setValue(getEntry<double>(config, ORIGIN_PZ_KEY));
origin_ui_->double_spin_box_qx->setValue(getEntry<double>(config, ORIGIN_QX_KEY));
origin_ui_->double_spin_box_qy->setValue(getEntry<double>(config, ORIGIN_QY_KEY));
origin_ui_->double_spin_box_qz->setValue(getEntry<double>(config, ORIGIN_QZ_KEY));
origin_ui_->double_spin_box_qw->setValue(getEntry<double>(config, ORIGIN_QW_KEY));

Eigen::Vector2d plane_dim(getEntry<double>(config, PLANE_X_DIM_KEY), getEntry<double>(config, PLANE_Y_DIM_KEY));
plane_dim_ui_->double_spin_box_x->setValue(getEntry<double>(config, PLANE_X_DIM_KEY));
plane_dim_ui_->double_spin_box_y->setValue(getEntry<double>(config, PLANE_Y_DIM_KEY));

Eigen::Vector2d spacing(getEntry<double>(config, X_SPACING_KEY), getEntry<double>(config, Y_SPACING_KEY));
spacing_dim_ui_->double_spin_box_x->setValue(getEntry<double>(config, X_SPACING_KEY));
spacing_dim_ui_->double_spin_box_y->setValue(getEntry<double>(config, Y_SPACING_KEY));
}

void FlatPlaneToolPathPlannerWidget::save(YAML::Node& config) const
{
config[ORIGIN_PX_KEY] = origin_ui_->double_spin_box_px->value();
config[ORIGIN_PY_KEY] = origin_ui_->double_spin_box_py->value();
config[ORIGIN_PZ_KEY] = origin_ui_->double_spin_box_pz->value();
config[ORIGIN_QX_KEY] = origin_ui_->double_spin_box_qx->value();
config[ORIGIN_QY_KEY] = origin_ui_->double_spin_box_qy->value();
config[ORIGIN_QZ_KEY] = origin_ui_->double_spin_box_qz->value();
config[ORIGIN_QW_KEY] = origin_ui_->double_spin_box_qw->value();

config[PLANE_X_DIM_KEY] = plane_dim_ui_->double_spin_box_x->value();
config[PLANE_Y_DIM_KEY] = plane_dim_ui_->double_spin_box_y->value();

config[X_SPACING_KEY] = spacing_dim_ui_->double_spin_box_x->value();
config[Y_SPACING_KEY] = spacing_dim_ui_->double_spin_box_y->value();
}

} // namespace noether
Loading
Loading