Skip to content

Commit

Permalink
Minor formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSpielman committed Jan 5, 2024
1 parent 23a0129 commit ee2cba1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
3 changes: 1 addition & 2 deletions noether_gui/src/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ struct WidgetPluginImpl : WidgetPlugin<BaseT>
}
};
// Tool Path Planners
using FlatPlaneToolPathPlannerWidgetPlugin =
WidgetPluginImpl<FlatPlaneToolPathPlannerWidget, ToolPathPlannerWidget>;
using FlatPlaneToolPathPlannerWidgetPlugin = WidgetPluginImpl<FlatPlaneToolPathPlannerWidget, ToolPathPlannerWidget>;

// Direction Generators
using FixedDirectionGeneratorWidgetPlugin =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#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";
Expand All @@ -22,12 +21,13 @@ 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())
: 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);
Expand Down Expand Up @@ -74,22 +74,24 @@ 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());
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());
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());
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));
Expand Down Expand Up @@ -124,7 +126,6 @@ void FlatPlaneToolPathPlannerWidget::save(YAML::Node& config) const

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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ namespace noether
class FlatPlaneToolPathPlanner : public ToolPathPlanner
{
public:
FlatPlaneToolPathPlanner(const Eigen::Vector2d& plane_dims, const Eigen::Vector2d& point_spacing, Eigen::Isometry3d offset = Eigen::Isometry3d::Identity());
FlatPlaneToolPathPlanner(const Eigen::Vector2d& plane_dims,
const Eigen::Vector2d& point_spacing,
Eigen::Isometry3d offset = Eigen::Isometry3d::Identity());
ToolPaths plan(const pcl::PolygonMesh& mesh) const override final;

private:
Expand Down
17 changes: 10 additions & 7 deletions noether_tpp/src/tool_path_planners/flat_plane_toolpath_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace noether
{
FlatPlaneToolPathPlanner::FlatPlaneToolPathPlanner(const Eigen::Vector2d& plane_dims, const Eigen::Vector2d& point_spacing, Eigen::Isometry3d offset)
FlatPlaneToolPathPlanner::FlatPlaneToolPathPlanner(const Eigen::Vector2d& plane_dims,
const Eigen::Vector2d& point_spacing,
Eigen::Isometry3d offset)
: plane_dims_(plane_dims), point_spacing_(point_spacing), offset_(offset)
{
}
Expand All @@ -15,24 +17,25 @@ ToolPaths FlatPlaneToolPathPlanner::plan(const pcl::PolygonMesh& /*mesh*/) const
ToolPaths tool_paths;

Eigen::Isometry3d eigen_pose = offset_;
for(size_t i = 0; plane_dims_[0] - point_spacing_[0]*i >= 0; i++)
for (size_t i = 0; plane_dims_[0] - point_spacing_[0] * i >= 0; i++)
{
for(size_t j = 0; plane_dims_[1] - point_spacing_[1]*j >= 0; j++)
for (size_t j = 0; plane_dims_[1] - point_spacing_[1] * j >= 0; j++)
{
Eigen::Isometry3d pt = eigen_pose * Eigen::Translation3d(i*point_spacing_[0],j*point_spacing_[1], 0.0);
Eigen::Isometry3d pt = eigen_pose * Eigen::Translation3d(i * point_spacing_[0], j * point_spacing_[1], 0.0);
segment.push_back(pt);
}
if (i % 2 != 0) {
if (i % 2 != 0)
{
std::reverse(segment.begin(), segment.end());
tool_path.push_back(segment);
}
else{
else
{
tool_path.push_back(segment);
}
segment.clear();
}
tool_paths.push_back(tool_path);
return tool_paths;

}
} // namespace noether

0 comments on commit ee2cba1

Please sign in to comment.