Skip to content

Commit

Permalink
Add Task Composer Widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Armstrong committed Oct 15, 2024
1 parent 207dcc8 commit 4062cc3
Show file tree
Hide file tree
Showing 58 changed files with 2,136 additions and 96 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ set(DEPS
tesseract_environment
tesseract_scene_graph
tesseract_common
tesseract_support
tesseract_urdf
tesseract_srdf
tesseract_visualization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define TESSERACT_QT_COMMAND_LANGUAGE_COMPOSITE_INSTRUCTION_STANDARD_ITEM_H

#include <QStandardItem>
#include <tesseract_command_language/fwd.h>
#include <tesseract_command_language/composite_instruction.h>

namespace tesseract_gui
{
Expand All @@ -38,7 +38,10 @@ class CompositeInstructionStandardItem : public QStandardItem
const tesseract_planning::CompositeInstruction& ci);
int type() const override;

const tesseract_planning::CompositeInstruction& getCompositeInstruction() const;

private:
tesseract_planning::CompositeInstruction ci_;
void ctor(const tesseract_planning::CompositeInstruction& ci);
};
} // namespace tesseract_gui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <tesseract_qt/common/models/standard_item_utils.h>
#include <tesseract_qt/common/icon_utils.h>

#include <tesseract_command_language/composite_instruction.h>
#include <tesseract_command_language/move_instruction.h>
#include <tesseract_command_language/poly/instruction_poly.h>

Expand Down Expand Up @@ -64,6 +63,11 @@ int CompositeInstructionStandardItem::type() const
return static_cast<int>(StandardItemType::CL_COMPOSITE_INSTRUCTION);
}

const tesseract_planning::CompositeInstruction& CompositeInstructionStandardItem::getCompositeInstruction() const
{
return ci_;
}

std::string toString(tesseract_planning::CompositeInstructionOrder order)
{
switch (order)
Expand All @@ -81,12 +85,13 @@ std::string toString(tesseract_planning::CompositeInstructionOrder order)

void CompositeInstructionStandardItem::ctor(const tesseract_planning::CompositeInstruction& ci)
{
ci_ = ci;
appendRow(createStandardItemString("description", ci.getDescription()));
appendRow(createStandardItemString("order", toString(ci.getOrder())));
appendRow(createStandardItemString("profile", ci.getProfile()));
appendRow(createStandardItemString("uuid", boost::uuids::to_string(ci.getUUID())));
appendRow(createStandardItemString("parent uuid", boost::uuids::to_string(ci.getParentUUID())));
appendRow(new ManipulatorInfoStandardItem("manip info", ci.getManipulatorInfo()));
appendRow(new VectorInstructionStandardItem("instructions", ci.getInstructions()));
appendRow(new ManipulatorInfoStandardItem("manip info", ci.getManipulatorInfo())); // NOLINT
appendRow(new VectorInstructionStandardItem("instructions", ci.getInstructions())); // NOLINT
}
} // namespace tesseract_gui
1 change: 1 addition & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ add_library(
src/events/render_events.cpp
src/events/scene_graph_events.cpp
src/events/scene_graph_render_manager.cpp
src/events/task_composer_events.cpp
src/events/tool_path_events.cpp
src/events/tool_path_render_manager.cpp
src/factories/any_poly_standard_item_factory.cpp
Expand Down
9 changes: 9 additions & 0 deletions common/include/tesseract_qt/common/events/event_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ enum class EventType : int
MANIPULATION_TYPES_START = JOINT_TRAJECTORY_TYPES_END,
MANIPULATION_CHANGED = MANIPULATION_TYPES_START + 1,
MANIPULATION_TYPES_END = MANIPULATION_TYPES_START + 2,

// Task Composer
TASK_COMPOSER_TYPES_START = MANIPULATION_TYPES_END,
TASK_COMPOSER_LOAD_CONFIG = TASK_COMPOSER_TYPES_START + 1,
TASK_COMPOSER_LOAD_LOG = TASK_COMPOSER_TYPES_START + 2,
TASK_COMPOSER_SAVE_LOG = TASK_COMPOSER_TYPES_START + 3,
TASK_COMPOSER_PLOT_DOTGRAPH = TASK_COMPOSER_TYPES_START + 4,
TASK_COMPOSER_SET_PROFILES = TASK_COMPOSER_TYPES_START + 5,
TASK_COMPOSER_TYPES_END = TASK_COMPOSER_TYPES_START + 6,
};
}

Expand Down
109 changes: 109 additions & 0 deletions common/include/tesseract_qt/common/events/task_composer_events.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* @author Levi Armstrong <[email protected]>
*
* @copyright Copyright (C) 2024 Levi Armstrong <[email protected]>
*
* @par License
* GNU Lesser General Public License Version 3, 29 June 2007
* @par
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* @par
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @par
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TESSERACT_QT_COMMON_TASK_COMPOSER_EVENTS_H
#define TESSERACT_QT_COMMON_TASK_COMPOSER_EVENTS_H

#include <tesseract_command_language/fwd.h>
#include <tesseract_qt/common/events/event_type.h>
#include <tesseract_qt/common/events/component_events.h>
#include <tesseract_common/filesystem.h>

namespace tesseract_gui::events
{
class TaskComposerLoadConfig : public ComponentEvent
{
public:
TaskComposerLoadConfig(std::shared_ptr<const ComponentInfo> component_info, std::string resource_path);
~TaskComposerLoadConfig() override;

const std::string& getResourcePath() const;

/** @brief Unique type for this event. */
static const QEvent::Type kType = QEvent::Type(EventType::TASK_COMPOSER_LOAD_CONFIG);

private:
std::string resource_path_;
};

class TaskComposerLoadLog : public ComponentEvent
{
public:
TaskComposerLoadLog(std::shared_ptr<const ComponentInfo> component_info,
std::string resource_path,
std::string ns = "");
~TaskComposerLoadLog() override;

const std::string& getResourcePath() const;
const std::string& getNamespace() const;

/** @brief Unique type for this event. */
static const QEvent::Type kType = QEvent::Type(EventType::TASK_COMPOSER_LOAD_LOG);

private:
std::string resource_path_;
std::string ns_;
};

class TaskComposerSaveLog : public ComponentEvent
{
public:
TaskComposerSaveLog(std::shared_ptr<const ComponentInfo> component_info, std::string save_path);
~TaskComposerSaveLog() override;

const std::string& getSavePath() const;

/** @brief Unique type for this event. */
static const QEvent::Type kType = QEvent::Type(EventType::TASK_COMPOSER_SAVE_LOG);

private:
std::string save_path_;
};

class TaskComposerPlotDotgraph : public ComponentEvent
{
public:
TaskComposerPlotDotgraph(std::shared_ptr<const ComponentInfo> component_info);
~TaskComposerPlotDotgraph() override;

/** @brief Unique type for this event. */
static const QEvent::Type kType = QEvent::Type(EventType::TASK_COMPOSER_PLOT_DOTGRAPH);
};

class TaskComposerSetProfiles : public ComponentEvent
{
public:
TaskComposerSetProfiles(std::shared_ptr<const ComponentInfo> component_info,
std::shared_ptr<tesseract_planning::ProfileDictionary> profiles);
~TaskComposerSetProfiles() override;

std::shared_ptr<tesseract_planning::ProfileDictionary> getProfiles() const;

/** @brief Unique type for this event. */
static const QEvent::Type kType = QEvent::Type(EventType::TASK_COMPOSER_SET_PROFILES);

private:
std::shared_ptr<tesseract_planning::ProfileDictionary> profiles_;
};
} // namespace tesseract_gui::events

#endif // TESSERACT_QT_COMMON_TASK_COMPOSER_EVENTS_H
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ enum class StandardItemType : int
MP_TASK_COMPOSER_NODE_INFO = CL_TYPES_END + 5,
MP_TASK_COMPOSER_NODE_INFO_MAP = CL_TYPES_END + 6,
MP_TASK_COMPOSER_DATA_STORAGE = CL_TYPES_END + 7,
MP_TYPES_END = CL_TYPES_END + 8,
MP_TASK_COMPOSER_LOG = CL_TYPES_END + 8,
MP_TYPES_END = CL_TYPES_END + 9,

};
// clang-format on
Expand Down
82 changes: 82 additions & 0 deletions common/src/events/task_composer_events.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* @author Levi Armstrong <[email protected]>
*
* @copyright Copyright (C) 2024 Levi Armstrong <[email protected]>
*
* @par License
* GNU Lesser General Public License Version 3, 29 June 2007
* @par
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* @par
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* @par
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <tesseract_qt/common/events/task_composer_events.h>

namespace tesseract_gui::events
{
TaskComposerLoadConfig::TaskComposerLoadConfig(std::shared_ptr<const ComponentInfo> component_info,
std::string resource_path)
: ComponentEvent(std::move(component_info), kType), resource_path_(std::move(resource_path))
{
}

TaskComposerLoadConfig::~TaskComposerLoadConfig() = default;
const std::string& TaskComposerLoadConfig::getResourcePath() const { return resource_path_; }

//////////////////////////////////////////////////////

TaskComposerLoadLog::TaskComposerLoadLog(std::shared_ptr<const ComponentInfo> component_info,
std::string resource_path,
std::string ns)
: ComponentEvent(std::move(component_info), kType), resource_path_(std::move(resource_path)), ns_(std::move(ns))
{
}

TaskComposerLoadLog::~TaskComposerLoadLog() = default;
const std::string& TaskComposerLoadLog::getResourcePath() const { return resource_path_; }
const std::string& TaskComposerLoadLog::getNamespace() const { return ns_; }

//////////////////////////////////////////////////////

TaskComposerSaveLog::TaskComposerSaveLog(std::shared_ptr<const ComponentInfo> component_info, std::string save_path)
: ComponentEvent(std::move(component_info), kType), save_path_(std::move(save_path))
{
}

TaskComposerSaveLog::~TaskComposerSaveLog() = default;
const std::string& TaskComposerSaveLog::getSavePath() const { return save_path_; }

//////////////////////////////////////////////////////

TaskComposerPlotDotgraph::TaskComposerPlotDotgraph(std::shared_ptr<const ComponentInfo> component_info)
: ComponentEvent(std::move(component_info), kType)
{
}

TaskComposerPlotDotgraph::~TaskComposerPlotDotgraph() = default;

//////////////////////////////////////////////////////

TaskComposerSetProfiles::TaskComposerSetProfiles(std::shared_ptr<const ComponentInfo> component_info,
std::shared_ptr<tesseract_planning::ProfileDictionary> profiles)
: ComponentEvent(std::move(component_info), kType), profiles_(std::move(profiles))
{
}

TaskComposerSetProfiles::~TaskComposerSetProfiles() = default;
std::shared_ptr<tesseract_planning::ProfileDictionary> TaskComposerSetProfiles::getProfiles() const
{
return profiles_;
}
} // namespace tesseract_gui::events
4 changes: 1 addition & 3 deletions environment/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
find_package(tesseract_support REQUIRED)
find_package(tesseract_urdf REQUIRED)
find_package(tesseract_srdf REQUIRED)

add_executable(${PROJECT_NAME}_environment_demo environment_demo.cpp)
target_link_libraries(
${PROJECT_NAME}_environment_demo
PRIVATE tesseract::tesseract_support
tesseract::tesseract_urdf
PRIVATE tesseract::tesseract_urdf
tesseract::tesseract_srdf
${PROJECT_NAME}_environment_widgets
${PROJECT_NAME}_common)
Expand Down
10 changes: 6 additions & 4 deletions environment/demo/environment_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@
#include <tesseract_qt/common/environment_wrapper.h>

#include <tesseract_environment/environment.h>
#include <tesseract_support/tesseract_support_resource_locator.h>
#include <tesseract_common/resource_locator.h>

int main(int argc, char** argv)
{
QApplication app(argc, argv);

Q_INIT_RESOURCE(tesseract_qt_resources);

auto locator = std::make_shared<tesseract_common::TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path = std::string(TESSERACT_SUPPORT_DIR) + "/urdf/lbr_iiwa_14_r820.urdf";
tesseract_common::fs::path srdf_path = std::string(TESSERACT_SUPPORT_DIR) + "/urdf/lbr_iiwa_14_r820.srdf";
auto locator = std::make_shared<tesseract_common::GeneralResourceLocator>();
tesseract_common::fs::path urdf_path(
locator->locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.urdf")->getFilePath());
tesseract_common::fs::path srdf_path(
locator->locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.srdf")->getFilePath());

auto env = std::make_shared<tesseract_environment::Environment>();
env->init(urdf_path, srdf_path, locator);
Expand Down
5 changes: 2 additions & 3 deletions joint_state_slider/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
find_package(tesseract_support REQUIRED)
find_package(tesseract_urdf REQUIRED)

add_executable(${PROJECT_NAME}_joint_state_slider_demo joint_state_slider_demo.cpp)
target_link_libraries(${PROJECT_NAME}_joint_state_slider_demo
PRIVATE ${PROJECT_NAME}_joint_state_slider tesseract::tesseract_support tesseract::tesseract_urdf)
target_link_libraries(${PROJECT_NAME}_joint_state_slider_demo PRIVATE ${PROJECT_NAME}_joint_state_slider
tesseract::tesseract_urdf)

install_targets(TARGETS ${PROJECT_NAME}_joint_state_slider_demo)
6 changes: 3 additions & 3 deletions joint_state_slider/demo/joint_state_slider_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
#include <tesseract_urdf/urdf_parser.h>
#include <tesseract_scene_graph/graph.h>
#include <tesseract_scene_graph/joint.h>
#include <tesseract_support/tesseract_support_resource_locator.h>
#include <tesseract_common/resource_locator.h>

int main(int argc, char** argv)
{
QApplication app(argc, argv);

// Load Scene Graph
std::string path = std::string(TESSERACT_SUPPORT_DIR) + "/urdf/lbr_iiwa_14_r820.urdf";
tesseract_common::TesseractSupportResourceLocator locator;
tesseract_common::GeneralResourceLocator locator;
std::string path = locator.locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.urdf")->getFilePath();
tesseract_scene_graph::SceneGraph::UPtr sg = tesseract_urdf::parseURDFFile(path, locator);
std::vector<tesseract_scene_graph::Joint::ConstPtr> joints;
for (const auto& joint : sg->getJoints())
Expand Down
6 changes: 2 additions & 4 deletions kinematic_groups/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
find_package(tesseract_support REQUIRED)
find_package(tesseract_urdf REQUIRED)

add_executable(${PROJECT_NAME}_kinematic_groups_demo kinematic_group_demo.cpp)
target_link_libraries(${PROJECT_NAME}_kinematic_groups_demo PRIVATE ${PROJECT_NAME}_kinematic_groups_widgets)

add_executable(${PROJECT_NAME}_groups_joint_states_demo groups_joint_states_demo.cpp)
target_link_libraries(
${PROJECT_NAME}_groups_joint_states_demo PRIVATE ${PROJECT_NAME}_kinematic_groups_widgets
tesseract::tesseract_support tesseract::tesseract_urdf)
target_link_libraries(${PROJECT_NAME}_groups_joint_states_demo PRIVATE ${PROJECT_NAME}_kinematic_groups_widgets
tesseract::tesseract_urdf)

install_targets(TARGETS ${PROJECT_NAME}_kinematic_groups_demo ${PROJECT_NAME}_groups_joint_states_demo)
6 changes: 3 additions & 3 deletions kinematic_groups/demo/groups_joint_states_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <tesseract_qt/kinematic_groups/widgets/group_joint_states_editor_widget.h>

#include <tesseract_urdf/urdf_parser.h>
#include <tesseract_support/tesseract_support_resource_locator.h>
#include <tesseract_common/resource_locator.h>

int main(int argc, char** argv)
{
Expand All @@ -35,8 +35,8 @@ int main(int argc, char** argv)
Q_INIT_RESOURCE(tesseract_qt_resources);

// Load Scene Graph
std::string path = std::string(TESSERACT_SUPPORT_DIR) + "/urdf/lbr_iiwa_14_r820.urdf";
tesseract_common::TesseractSupportResourceLocator locator;
tesseract_common::GeneralResourceLocator locator;
std::string path = locator.locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.urdf")->getFilePath();

/** @todo need to load environment */

Expand Down
Loading

0 comments on commit 4062cc3

Please sign in to comment.