From 7a132070f0b09bf192a8392962bf0bfc80fec239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Cie=C5=9Blak?= Date: Thu, 8 Sep 2022 20:06:33 +0200 Subject: [PATCH 01/28] Fixed linking with BehaviorTrees already installed on the system. (#167) Co-authored-by: Patryk Cieslak --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 129ad981..208b7430 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,8 @@ set(CATKIN_ENABLE_TESTING OFF CACHE BOOL "") if(NOT catkin_FOUND AND NOT ament_cmake_FOUND) # look for BehaviorTree.CPP on the system - find_package(BehaviorTreeV3) - if (NOT BehaviorTree_FOUND) + find_package(behaviortree_cpp_v3) + if (NOT behaviortree_cpp_v3_FOUND) # use git submodule only if you are not compiling with catkin add_subdirectory( depend/BehaviorTree.CPP ) include_directories( depend/BehaviorTree.CPP/include ) From 8eec90bea1ab9c1276eaa4e4ddd3661bfffbb65c Mon Sep 17 00:00:00 2001 From: MozgovoyOleg Date: Thu, 8 Sep 2022 21:08:07 +0300 Subject: [PATCH 02/28] fix node style for idle trail (#161) --- bt_editor/graphic_container.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bt_editor/graphic_container.cpp b/bt_editor/graphic_container.cpp index 421400c8..3dfce1b6 100644 --- a/bt_editor/graphic_container.cpp +++ b/bt_editor/graphic_container.cpp @@ -137,17 +137,16 @@ void GraphicContainer::lockSubtreeEditing(Node &root_node, bool locked, bool cha } } //-------------------------------- - QtNodes::NodeStyle style; - if( locked && change_style ) { + QtNodes::NodeStyle style; style.GradientColor0.setBlue(120); style.GradientColor1.setBlue(100); style.GradientColor2.setBlue(90); style.GradientColor3.setBlue(90); + node->nodeDataModel()->setNodeStyle( style ); } node->nodeGraphicsObject().setGeometryChanged(); - node->nodeDataModel()->setNodeStyle( style ); node->nodeGraphicsObject().update(); } } From eb0a1f2c21f7ee95bc9c12da0611aba73479b2fd Mon Sep 17 00:00:00 2001 From: Tim Clephas Date: Thu, 8 Sep 2022 20:09:40 +0200 Subject: [PATCH 03/28] No need for line ending as the xml_text already contains it (#164) --- bt_editor/mainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bt_editor/mainwindow.cpp b/bt_editor/mainwindow.cpp index ad8a8ed9..3fdd611f 100644 --- a/bt_editor/mainwindow.cpp +++ b/bt_editor/mainwindow.cpp @@ -151,7 +151,7 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) : { if (prev_ID == new_ID) return; - + for (int index = 0; index < ui->tabWidget->count(); index++) { if( ui->tabWidget->tabText(index) == prev_ID) @@ -647,7 +647,7 @@ void MainWindow::on_actionSave_triggered() QFile file(fileName); if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); - stream << xml_text << endl; + stream << xml_text; } directory_path = QFileInfo(fileName).absolutePath(); From db69e854f8aadccaf06c02bd799a13fe083e4079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isac=20T=C3=B6rnberg?= Date: Sun, 9 Oct 2022 10:55:49 +0200 Subject: [PATCH 04/28] Added check for nullptr when expanding SubTree (#136) --- bt_editor/mainwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bt_editor/mainwindow.cpp b/bt_editor/mainwindow.cpp index 3fdd611f..8309ea75 100644 --- a/bt_editor/mainwindow.cpp +++ b/bt_editor/mainwindow.cpp @@ -1045,6 +1045,12 @@ QtNodes::Node* MainWindow::subTreeExpand(GraphicContainer &container, if( option == SUBTREE_EXPAND && subtree_model->expanded() == false) { auto subtree_container = getTabByName(subtree_name); + if (!subtree_container) { + QMessageBox::warning(this, tr("Oops!"), + tr("Couldn't get SubTree name from tabs and therefore can't expand."), + QMessageBox::Cancel); + return &node; + } // Prevent expansion of invalid subtree if( !subtree_container->containsValidTree() ) From 417428bd02c34ea055c1a0bb5a8a0b96ddf3e5fb Mon Sep 17 00:00:00 2001 From: "Affonso, Guilherme" Date: Sun, 9 Oct 2022 17:57:32 +0900 Subject: [PATCH 05/28] Fix references to RetryUntilSuccesful (#168) --- bt_editor/resources/NodesStyle.json | 2 +- test_data/Simple.xml | 4 ++-- test_data/crossdoor_with_subtree.xml | 4 ++-- test_data/show_all.xml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bt_editor/resources/NodesStyle.json b/bt_editor/resources/NodesStyle.json index efeccc5e..a0fd76dc 100644 --- a/bt_editor/resources/NodesStyle.json +++ b/bt_editor/resources/NodesStyle.json @@ -42,7 +42,7 @@ "icon": ":/icons/svg/edit_list.svg" }, - "RetryUntilSuccesful": { + "RetryUntilSuccessful": { "icon": ":/icons/svg/retry.svg" }, diff --git a/test_data/Simple.xml b/test_data/Simple.xml index 7ab3d915..99d33cb4 100644 --- a/test_data/Simple.xml +++ b/test_data/Simple.xml @@ -2,9 +2,9 @@ - + - + diff --git a/test_data/crossdoor_with_subtree.xml b/test_data/crossdoor_with_subtree.xml index 5d02f311..19f9f0f2 100644 --- a/test_data/crossdoor_with_subtree.xml +++ b/test_data/crossdoor_with_subtree.xml @@ -6,9 +6,9 @@ - + - + diff --git a/test_data/show_all.xml b/test_data/show_all.xml index 89daa0ed..d2b1f149 100644 --- a/test_data/show_all.xml +++ b/test_data/show_all.xml @@ -10,11 +10,11 @@ - + - + From 2515530df24715b9fc961d87723561abf88f7668 Mon Sep 17 00:00:00 2001 From: kogut Date: Sun, 9 Oct 2022 02:01:02 -0700 Subject: [PATCH 06/28] Cleaning up minor warnings (#123) * Cleaned up minor gcc warnings related to zmq usage and minor abuse of an index variable. * Handling case where optional return isn't returned from recv. Co-authored-by: Greg Kogut --- QtNodeEditor/src/NodeState.cpp | 3 +-- bt_editor/sidepanel_monitor.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/QtNodeEditor/src/NodeState.cpp b/QtNodeEditor/src/NodeState.cpp index 711f3663..53f310b9 100644 --- a/QtNodeEditor/src/NodeState.cpp +++ b/QtNodeEditor/src/NodeState.cpp @@ -48,7 +48,7 @@ NodeState:: connections(PortType portType, PortIndex portIndex) const { auto const &connections = getEntries(portType); - if( portIndex < 0 || portIndex >= connections.size() ) + if( portIndex < 0 || static_cast(portIndex) >= connections.size() ) { return NodeState::ConnectionPtrSet(); } @@ -139,4 +139,3 @@ resizing() const { return _resizing; } - diff --git a/bt_editor/sidepanel_monitor.cpp b/bt_editor/sidepanel_monitor.cpp index acd0fe20..0efb560d 100644 --- a/bt_editor/sidepanel_monitor.cpp +++ b/bt_editor/sidepanel_monitor.cpp @@ -41,7 +41,7 @@ void SidepanelMonitor::on_timer() zmq::message_t msg; try{ - while( _zmq_subscriber.recv(&msg) ) + while( _zmq_subscriber.recv(msg) ) { _msg_count++; ui->labelCount->setText( QString("Messages received: %1").arg(_msg_count) ); @@ -50,7 +50,7 @@ void SidepanelMonitor::on_timer() const uint32_t header_size = flatbuffers::ReadScalar( buffer ); const uint32_t num_transitions = flatbuffers::ReadScalar( &buffer[4+header_size] ); - + std::vector> node_status; // check uid in the index, if failed load tree from server try{ @@ -59,7 +59,7 @@ void SidepanelMonitor::on_timer() const uint16_t uid = flatbuffers::ReadScalar(&buffer[offset]); _uid_to_index.at(uid); } - + for(size_t t=0; t < num_transitions; t++) { size_t offset = 8 + header_size + 12*t; @@ -130,10 +130,10 @@ bool SidepanelMonitor::getTreeFromServer() int timeout_ms = 1000; zmq_client.setsockopt(ZMQ_RCVTIMEO,&timeout_ms, sizeof(int) ); - zmq_client.send(request); + zmq_client.send(request, zmq::send_flags::none); - bool received = zmq_client.recv(&reply); - if( ! received ) + auto bytes_received = zmq_client.recv(reply, zmq::recv_flags::none); + if( !bytes_received || *bytes_received == 0 ) { return false; } From 063af796bfeece91564fd49b7bc0a08403ade555 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Sun, 9 Oct 2022 11:10:01 +0200 Subject: [PATCH 07/28] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 2677a5bd..f25b0754 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ [![Build Status](https://travis-ci.org/BehaviorTree/Groot.svg?branch=master)](https://travis-ci.org/BehaviorTree/Groot) +# DEPRECATION notice + +Groot is being rewritten from the ground up (**new software COMING SOON**). This repository will be in "maintenance mode" and won't receive any +significant update. +Issues will **not** be addressed by the main author but, occasionally, Pull Requests might be checked and merged. + +**If you use Groot at your company** and you want to know how we are redesigning it to be more flexible, reliable, fast and scalable, +then get in touch with the main author: dfaconti@aurynrobotics.com. + # Groot **Groot** is a Graphical Editor, written in C++ and Qt, to create [BehaviorTrees](https://en.wikipedia.org/wiki/Behavior_tree). From b235419d4d53a109de11917ba969ba12460d005e Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Fri, 4 Nov 2022 09:27:50 +0100 Subject: [PATCH 08/28] readme modified --- README.md | 38 ++++++++++++++++++++++---------------- package.xml | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f25b0754..85541749 100644 --- a/README.md +++ b/README.md @@ -45,25 +45,31 @@ On Ubuntu Xenial or later, you can install the dependencies with: Some functionalities of the code related to ROS will work __only__ if the project is compiled with with _catkin_. -# Compilation instructions (Linux) - - git clone https://github.com/BehaviorTree/Groot.git - cd Groot - git submodule update --init --recursive - mkdir build; cd build - cmake .. - make +## Compilation instructions (Linux) + +``` +git clone https://github.com/BehaviorTree/Groot.git +cd Groot +git submodule update --init --recursive +mkdir build; cd build +cmake .. +make +``` Note compiling "in-source" is not allowed. - # Compilation instructions (ROS) - - mkdir -p catkin_ws/src - cd catkin_ws/src - git clone https://github.com/BehaviorTree/Groot.git - cd .. - rosdep install --from-paths src --ignore-src - catkin_make + ## Compilation instructions (ROS/ROS2) + +**Discouraged** + +If you want to compile using `catkin build`(ROS) or `colcon_build` (ROS2) +then you must be sure that version 3.8.x is used (branch V3.8). + +You may probably want to compile BehaviorTree.CPP in the same workspace. + +``` +git clone --branch v3.8 https://github.com/BehaviorTree/BehaviorTree.CPP.git +``` # Licence diff --git a/package.xml b/package.xml index 50a9de59..1c4da150 100644 --- a/package.xml +++ b/package.xml @@ -27,7 +27,7 @@ libdw-dev libzmq3-dev - behaviortree_cpp_v3 + behaviortree_cpp_v3 catkin From 016477285af73949c78c78a0d7d9fe7f7e308584 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Fri, 4 Nov 2022 09:47:23 +0100 Subject: [PATCH 09/28] README --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 85541749..e08525ac 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,17 @@ # DEPRECATION notice -Groot is being rewritten from the ground up (**new software COMING SOON**). This repository will be in "maintenance mode" and won't receive any -significant update. +Groot is being rewritten from the ground up (**new software COMING SOON**). +This repository will be in "maintenance mode" and won't receive any significant update. Issues will **not** be addressed by the main author but, occasionally, Pull Requests might be checked and merged. -**If you use Groot at your company** and you want to know how we are redesigning it to be more flexible, reliable, fast and scalable, -then get in touch with the main author: dfaconti@aurynrobotics.com. +**Groot 1.0 is compatble only with BehaviorTree.CPP 3.8.x**, and it is not expected to +work correctly with BehaviorTree.CPP 4.x. + +We are working on Groot 2.0, that will introduce new functionalities and compatibility with BT.CPP 4.0. + +**If you use Groot at work** and you want to know how we are redesigning it to be more flexible, +reliable, fast and scalable, get in touch with the main author: dfaconti@aurynrobotics.com. # Groot From 613eadb01371a87442627f3fb55d07b3ad86651d Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Fri, 4 Nov 2022 11:51:48 +0100 Subject: [PATCH 10/28] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e08525ac..6eb9dd6c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Groot is being rewritten from the ground up (**new software COMING SOON**). This repository will be in "maintenance mode" and won't receive any significant update. Issues will **not** be addressed by the main author but, occasionally, Pull Requests might be checked and merged. -**Groot 1.0 is compatble only with BehaviorTree.CPP 3.8.x**, and it is not expected to +**Groot 1.0 is compatible only with BehaviorTree.CPP 3.8.x**, and it is not expected to work correctly with BehaviorTree.CPP 4.x. We are working on Groot 2.0, that will introduce new functionalities and compatibility with BT.CPP 4.0. From e976bc42b7867bb666c709cfcadd0a2cf8f16902 Mon Sep 17 00:00:00 2001 From: El Jawad Alaa Date: Mon, 7 Nov 2022 17:15:49 +0100 Subject: [PATCH 11/28] use unordered_map instead of set when calling BT::VerifyXML (#180) --- bt_editor/XML_utilities.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bt_editor/XML_utilities.cpp b/bt_editor/XML_utilities.cpp index f26f3464..8ddbcd3f 100644 --- a/bt_editor/XML_utilities.cpp +++ b/bt_editor/XML_utilities.cpp @@ -2,10 +2,12 @@ #include "utils.h" #include "models/SubtreeNodeModel.hpp" +#include #include #include #include #include +#include using namespace QtNodes; @@ -189,11 +191,13 @@ bool VerifyXML(QDomDocument &doc, error_messages.clear(); try { std::string xml_text = doc.toString().toStdString(); - std::set registered_nodes; - + std::unordered_map registered_nodes; + + BT::NodeType node_type; for(const auto& str: registered_ID) { - registered_nodes.insert( str.toStdString() ); + node_type = BT::convertFromString(str.toStdString()); + registered_nodes.insert( {str.toStdString(), node_type}); } BT::VerifyXML(xml_text, registered_nodes); // may throw From ee66489e6ea9ea3cbdd866d869aca8ea621035ce Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Fri, 11 Nov 2022 10:41:04 +0100 Subject: [PATCH 12/28] use the correct BehaviorTree.CPP submodule --- CMakeLists.txt | 35 +++++++++++++++++++++++------------ depend/BehaviorTree.CPP | 2 +- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 208b7430..6581af0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,9 @@ if(ament_cmake_FOUND) behaviortree_cpp_v3 ) - message(STATUS "------------------------------------------------") - message(STATUS "BehaviourTreeEditor is being built using AMENT.") - message(STATUS "------------------------------------------------") + message(STATUS "---------------------") + message(STATUS "Compiling with AMENT.") + message(STATUS "---------------------") elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE) # http://answers.ros.org/question/230877/optionally-build-a-package-with-catkin/ set(catkin_FOUND 1) @@ -39,9 +39,9 @@ elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE) find_package(catkin REQUIRED COMPONENTS behaviortree_cpp_v3) - message(STATUS "------------------------------------------------") - message(STATUS "BehaviourTreeEditor is being built using CATKIN.") - message(STATUS "------------------------------------------------") + message(STATUS "----------------------") + message(STATUS "Compiling with CATKIN.") + message(STATUS "----------------------") catkin_package( INCLUDE_DIRS @@ -82,13 +82,24 @@ set(BUILD_TESTING OFF CACHE BOOL "") set(CATKIN_ENABLE_TESTING OFF CACHE BOOL "") if(NOT catkin_FOUND AND NOT ament_cmake_FOUND) - # look for BehaviorTree.CPP on the system - find_package(behaviortree_cpp_v3) - if (NOT behaviortree_cpp_v3_FOUND) - # use git submodule only if you are not compiling with catkin - add_subdirectory( depend/BehaviorTree.CPP ) - include_directories( depend/BehaviorTree.CPP/include ) + + if(NOT EXISTS depend/BehaviorTree.CPP) + message("Can't find the submodule BehaviorTree.CPP") + message("Run [git submodule update --init --recursive]") endif() + + SET(BUILD_EXAMPLES OFF CACHE BOOL "Build tutorials and examples" FORCE) + SET(BUILD_UNIT_TESTS OFF CACHE BOOL "Build the unit tests" FORCE) + SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries" FORCE) + + # look for BehaviorTree.CPP as submodule + # use git submodule only if you are not compiling with catkin + add_subdirectory( depend/BehaviorTree.CPP ) + include_directories( depend/BehaviorTree.CPP/include ) + + message(STATUS "----------------------------------") + message(STATUS "BehaviourTree.CPP submodule found.") + message(STATUS "----------------------------------") endif() ########################################## diff --git a/depend/BehaviorTree.CPP b/depend/BehaviorTree.CPP index 59c1a809..73e10fb8 160000 --- a/depend/BehaviorTree.CPP +++ b/depend/BehaviorTree.CPP @@ -1 +1 @@ -Subproject commit 59c1a809a60d3c077301e9e5a1789334406b15a1 +Subproject commit 73e10fb8b2a7088521352d6d11fcd8633ba6036c From ff374ca5c99980b394227e5cfb2f0f74d7b7574e Mon Sep 17 00:00:00 2001 From: Konstantinos Lyrakis <24938740+lyrakisk@users.noreply.github.com> Date: Fri, 11 Nov 2022 10:43:52 +0100 Subject: [PATCH 13/28] Update README.md (#175) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6eb9dd6c..c22edaeb 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ On Ubuntu Xenial or later, you can install the dependencies with: sudo apt install qtbase5-dev libqt5svg5-dev libzmq3-dev libdw-dev Some functionalities of the code related to ROS will work __only__ if the -project is compiled with with _catkin_. +project is compiled with _catkin_. ## Compilation instructions (Linux) From 14f9fca48106262a2f5795270441024872fd443a Mon Sep 17 00:00:00 2001 From: Austin Greisman <92941098+austin-InDro@users.noreply.github.com> Date: Fri, 11 Nov 2022 04:44:42 -0500 Subject: [PATCH 14/28] Update to linking for ROS2 compile (#163) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6581af0a..438497ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ add_library(behavior_tree_editor SHARED ${FORMS_HEADERS} ) -SET(GROOT_DEPENDENCIES QtNodeEditor ) +SET(GROOT_DEPENDENCIES QtNodeEditor curses ncursesw tinfo ) if(ament_cmake_FOUND) ament_target_dependencies(behavior_tree_editor ${dependencies}) From de7ab0ae0f0ca5ead785dd07f2d308b0c6888d7d Mon Sep 17 00:00:00 2001 From: Nisala Kalupahana Date: Fri, 11 Nov 2022 01:45:48 -0800 Subject: [PATCH 15/28] Fix build on macOS (#142) --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 438497ef..e4c3d486 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,7 +169,12 @@ else() endif() if( ZMQ_FOUND ) - SET(GROOT_DEPENDENCIES ${GROOT_DEPENDENCIES} zmq) + if (APPLE) + find_package(cppzmq) + SET(GROOT_DEPENDENCIES ${GROOT_DEPENDENCIES} cppzmq) + else() + SET(GROOT_DEPENDENCIES ${GROOT_DEPENDENCIES} zmq) + endif() endif() target_link_libraries(behavior_tree_editor ${GROOT_DEPENDENCIES} ) From 16041452977ad1f4d1857dff4ab613815f6d405a Mon Sep 17 00:00:00 2001 From: Dmitri <810523+dignakov@users.noreply.github.com> Date: Fri, 11 Nov 2022 04:48:24 -0500 Subject: [PATCH 16/28] added a check for catkin similar to ament to make the package compile with colcon and ROS1 (#129) Co-authored-by: Dmitri Co-authored-by: Davide Faconti --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4c3d486..4de06bfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ endif() ############################################################# find_package(ament_cmake QUIET) +find_package(catkin QUIET) if(ament_cmake_FOUND) find_package(ament_index_cpp REQUIRED) @@ -32,7 +33,7 @@ if(ament_cmake_FOUND) message(STATUS "---------------------") message(STATUS "Compiling with AMENT.") message(STATUS "---------------------") -elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE) +elseif(catkin_FOUND OR CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE ) # http://answers.ros.org/question/230877/optionally-build-a-package-with-catkin/ set(catkin_FOUND 1) # add_definitions( -DUSING_ROS ) From 8af9a076822f038b90ed8f333acf43b177dfcbb9 Mon Sep 17 00:00:00 2001 From: kogut Date: Fri, 11 Nov 2022 01:50:47 -0800 Subject: [PATCH 17/28] Fixed CMake command API error. (#122) Co-authored-by: Greg Kogut --- test/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4b2fdee6..126d5598 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,7 +15,7 @@ ENABLE_TESTING() function(CompileTest name) add_executable(${name} ${name}.cpp groot_test_base.cpp ${RESOURCE_FILES} ) target_link_libraries(${name} PRIVATE Qt5::Gui Qt5::Test behavior_tree_editor) - add_test(${name} COMMAND ${name}) + add_test(NAME ${name} COMMAND ${name}) endfunction() set(RESOURCE_FILES @@ -27,4 +27,3 @@ set(RESOURCE_FILES CompileTest( editor_test ) CompileTest( replay_test ) - From 2ce24c48e3616d2ca108efbbfcb22e1b859e63bb Mon Sep 17 00:00:00 2001 From: "Affonso, Guilherme" Date: Fri, 11 Nov 2022 18:52:13 +0900 Subject: [PATCH 18/28] Recenter view and set focus when initialized (#176) --- bt_editor/mainwindow.cpp | 8 ++++++++ bt_editor/mainwindow.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/bt_editor/mainwindow.cpp b/bt_editor/mainwindow.cpp index 8309ea75..df90b1d5 100644 --- a/bt_editor/mainwindow.cpp +++ b/bt_editor/mainwindow.cpp @@ -723,6 +723,14 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) } } +void MainWindow::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + currentTabInfo()->zoomHomeView(); + ui->centralwidget->setFocus(); + } +} + void MainWindow::resizeEvent(QResizeEvent *) { on_splitter_splitterMoved(); diff --git a/bt_editor/mainwindow.h b/bt_editor/mainwindow.h index ebfd2c70..6d9e0efa 100644 --- a/bt_editor/mainwindow.h +++ b/bt_editor/mainwindow.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -142,6 +143,8 @@ private slots: bool eventFilter(QObject *obj, QEvent *event) override; + void showEvent(QShowEvent *event) override; + void resizeEvent(QResizeEvent *) override; GraphicContainer* createTab(const QString &name); From d897a05761a5fc87bca27fe4dc8f6825bf96a430 Mon Sep 17 00:00:00 2001 From: fultoncjb Date: Fri, 11 Nov 2022 11:54:25 -0500 Subject: [PATCH 19/28] Change tab scope if the user double-clicks on a subtree (#146) Co-authored-by: Cam Fulton --- bt_editor/mainwindow.cpp | 15 +++++++++++++++ bt_editor/mainwindow.h | 2 ++ bt_editor/sidepanel_editor.cpp | 19 +++++++++++++++++++ bt_editor/sidepanel_editor.h | 4 ++++ 4 files changed, 40 insertions(+) diff --git a/bt_editor/mainwindow.cpp b/bt_editor/mainwindow.cpp index df90b1d5..21c9804c 100644 --- a/bt_editor/mainwindow.cpp +++ b/bt_editor/mainwindow.cpp @@ -146,6 +146,9 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) : this->createTab(ID); }); + connect(_editor_widget, &SidepanelEditor::setTabScope, + this, &MainWindow::onSubtreeSelected); + connect( _editor_widget, &SidepanelEditor::renameSubtree, this, [this](QString prev_ID, QString new_ID) { @@ -1719,3 +1722,15 @@ GraphicMode MainWindow::getGraphicMode(void) const { return _current_mode; } + +void MainWindow::onSubtreeSelected(const QString& subtreeName) +{ + for (int i = 0; i < ui->tabWidget->tabBar()->count(); ++i) + { + if (ui->tabWidget->tabBar()->tabText(i) == subtreeName) + { + ui->tabWidget->tabBar()->setCurrentIndex(i); + return; + } + } +} diff --git a/bt_editor/mainwindow.h b/bt_editor/mainwindow.h index 6d9e0efa..3bdb2aeb 100644 --- a/bt_editor/mainwindow.h +++ b/bt_editor/mainwindow.h @@ -91,6 +91,8 @@ public slots: void on_actionSave_triggered(); + void onSubtreeSelected(const QString& subtreeName); + void on_splitter_splitterMoved(int pos = 0, int index = 0); void on_toolButtonReorder_pressed(); diff --git a/bt_editor/sidepanel_editor.cpp b/bt_editor/sidepanel_editor.cpp index 7f5c433b..775f50a0 100644 --- a/bt_editor/sidepanel_editor.cpp +++ b/bt_editor/sidepanel_editor.cpp @@ -29,6 +29,9 @@ SidepanelEditor::SidepanelEditor(QtNodes::DataModelRegistry *registry, connect( ui->paletteTreeWidget, &QWidget::customContextMenuRequested, this, &SidepanelEditor::onContextMenu); + connect(ui->paletteTreeWidget, &QTreeWidget::itemDoubleClicked, + this, &SidepanelEditor::onDoubleClick); + auto table_header = ui->portsTableWidget->horizontalHeader(); table_header->setSectionResizeMode(0, QHeaderView::ResizeToContents); @@ -462,3 +465,19 @@ void SidepanelEditor::on_buttonLock_toggled(bool locked) ui->buttonLock->setIcon( locked ? icon_locked : icon_unlocked); updateTreeView(); } + +void SidepanelEditor::onDoubleClick(QTreeWidgetItem *item, int column) +{ + QString selected_name = item->text(0); + + if( ui->buttonLock->isChecked() || + BuiltinNodeModels().count( selected_name ) != 0 ) + { + return; + } + + if (item->parent() && item->parent()->text(0) == "SubTree") + { + emit setTabScope(selected_name); + } +} diff --git a/bt_editor/sidepanel_editor.h b/bt_editor/sidepanel_editor.h index 8897d4bc..54d78c06 100644 --- a/bt_editor/sidepanel_editor.h +++ b/bt_editor/sidepanel_editor.h @@ -47,6 +47,8 @@ private slots: void on_buttonLock_toggled(bool checked); + void onDoubleClick(QTreeWidgetItem *item, int column); + signals: void addNewModel(const NodeModel &new_model); @@ -61,6 +63,8 @@ private slots: void destroySubtree(QString ID); + void setTabScope(const QString& subtreeName); + private: Ui::SidepanelEditor *ui; NodeModels &_tree_nodes_model; From 3cd0c33e6b4b3134fc2bd87d3daadf0da5313af9 Mon Sep 17 00:00:00 2001 From: Chuck Claunch Date: Thu, 17 Nov 2022 08:50:57 -0600 Subject: [PATCH 20/28] Add missing dep to package.xml (#182) --- package.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/package.xml b/package.xml index 1c4da150..010b5115 100644 --- a/package.xml +++ b/package.xml @@ -14,6 +14,7 @@ catkin cmake_modules ament_cmake + ament_index_cpp behaviortree_cpp_v3 qtbase5-dev From 4b8f5d3b925514e51f24242eba3fb58595a32c3e Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 22 Nov 2022 16:18:36 +0100 Subject: [PATCH 21/28] Update README.md --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index c22edaeb..670c6742 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,6 @@ the graphic user interface are used to design and monitor a Behavior Tree. [![MOOD2Be](video_MOOD2Be.png)](https://vimeo.com/304651183) -# Does your company use BehaviorTree.CPP and Groot? - -No company, institution or public/private funding is currently supporting the development of BehaviorTree.CPP and Groot. As a consequence, my time to support **BehaviorTree.CPP** is very limited and I decided that I won't spend any time at all supporting **Groot**. -Pull Requests are welcome and will be reviewed, even if with some delay. - -If your company use this software, consider becoming a **sponsor** to support bug fixing and development of new features. You can find contact details in [package.xml](package.xml). - # Dependencies, Installation, and Usage To compile the project you need: From 7c7ba71025d8d936f1450918e4cd528a6701eb55 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Wed, 1 Feb 2023 14:56:31 +0100 Subject: [PATCH 22/28] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 670c6742..ff95c459 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ # DEPRECATION notice -Groot is being rewritten from the ground up (**new software COMING SOON**). +Groot is being rewritten from the ground up (https://www.behaviortree.dev/groot). This repository will be in "maintenance mode" and won't receive any significant update. -Issues will **not** be addressed by the main author but, occasionally, Pull Requests might be checked and merged. +Issues will **not** be addressed by the main author but, occasionally, Pull Requests **might** be checked and merged. **Groot 1.0 is compatible only with BehaviorTree.CPP 3.8.x**, and it is not expected to work correctly with BehaviorTree.CPP 4.x. -We are working on Groot 2.0, that will introduce new functionalities and compatibility with BT.CPP 4.0. +Groot 2.0 introduces many new functionalities and compatibility with BT.CPP 4.0. **If you use Groot at work** and you want to know how we are redesigning it to be more flexible, reliable, fast and scalable, get in touch with the main author: dfaconti@aurynrobotics.com. From 89ba0533c1177d90b0e9dc142734f83a206776c4 Mon Sep 17 00:00:00 2001 From: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:53:50 -0500 Subject: [PATCH 23/28] Add publisher/server and autoconnect args to BT Monitor (#170) * Add publisher/server and autoconnect args to BT Monitor * Add extended timeout to get behavior tree on autoconnect * Add address arg --- bt_editor/main.cpp | 27 +++++++++++++++++++- bt_editor/mainwindow.cpp | 33 +++++++++++++++++++----- bt_editor/mainwindow.h | 14 ++++++++-- bt_editor/sidepanel_monitor.cpp | 45 +++++++++++++++++++++++---------- bt_editor/sidepanel_monitor.h | 22 ++++++++++++++-- bt_editor/sidepanel_monitor.ui | 2 +- 6 files changed, 118 insertions(+), 25 deletions(-) diff --git a/bt_editor/main.cpp b/bt_editor/main.cpp index 077c3c35..d80e92ee 100644 --- a/bt_editor/main.cpp +++ b/bt_editor/main.cpp @@ -39,6 +39,23 @@ main(int argc, char *argv[]) "Start in one of these modes: [editor,monitor,replay]", "mode"); parser.addOption(mode_option); + + QCommandLineOption address_option(QStringList() << "address", + "Address to connect to (defaults to localhost)", + "address"); + parser.addOption(address_option); + QCommandLineOption pub_port_option(QStringList() << "publisher_port", + "Publisher port number (defaults to 1666)", + "publisher_port"); + parser.addOption(pub_port_option); + QCommandLineOption srv_port_option(QStringList() << "server_port", + "Server port number (defaults to 1667)", + "server_port"); + parser.addOption(srv_port_option); + QCommandLineOption autoconnect_option(QStringList() << "autoconnect", + "Autoconnect to monitor"); + parser.addOption(autoconnect_option); + parser.process( app ); QFile styleFile( ":/stylesheet.qss" ); @@ -88,7 +105,15 @@ main(int argc, char *argv[]) mode = dialog.getGraphicMode(); } - MainWindow win( mode ); + // Get the monitor options. + const QString monitor_address = parser.value(address_option); + const QString monitor_pub_port = parser.value(pub_port_option); + const QString monitor_srv_port = parser.value(srv_port_option); + const bool monitor_autoconnect = parser.isSet(autoconnect_option); + + // Start the main application. + MainWindow win( mode, monitor_address, monitor_pub_port, + monitor_srv_port, monitor_autoconnect ); win.show(); return app.exec(); } diff --git a/bt_editor/mainwindow.cpp b/bt_editor/mainwindow.cpp index 21c9804c..865a5fae 100644 --- a/bt_editor/mainwindow.cpp +++ b/bt_editor/mainwindow.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "editor_flowscene.h" #include "utils.h" @@ -40,11 +41,20 @@ using QtNodes::FlowScene; using QtNodes::NodeGraphicsObject; using QtNodes::NodeState; -MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow), - _current_mode(initial_mode), - _current_layout(QtNodes::PortLayout::Vertical) +MainWindow::MainWindow(GraphicMode initial_mode, + const QString& monitor_address, + const QString& monitor_pub_port, + const QString& monitor_srv_port, + const bool monitor_autoconnect, + QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow), + _current_mode(initial_mode), + _current_layout(QtNodes::PortLayout::Vertical), + _monitor_address(monitor_address), + _monitor_publisher_port(monitor_pub_port), + _monitor_server_port(monitor_srv_port), + _monitor_autoconnect(monitor_autoconnect) { ui->setupUi(this); @@ -96,7 +106,8 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) : ui->leftFrame->layout()->addWidget( _replay_widget ); #ifdef ZMQ_FOUND - _monitor_widget = new SidepanelMonitor(this); + _monitor_widget = new SidepanelMonitor( + this, _monitor_address, _monitor_publisher_port, _monitor_server_port); ui->leftFrame->layout()->addWidget( _monitor_widget ); connect( ui->toolButtonConnect, &QToolButton::clicked, @@ -104,6 +115,16 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) : connect( _monitor_widget, &SidepanelMonitor::connectionUpdate, this, &MainWindow::onConnectionUpdate ); + + if ( monitor_autoconnect ) + { + // If autoconnecting, increase the timeout to get the behavior tree to a + // larger value. This only lasts for one "connect" before returning to + // its default value. + _monitor_widget->set_load_tree_timeout_ms( + _monitor_widget->_load_tree_autoconnect_timeout_ms); + ui->toolButtonConnect->animateClick(); + } #else ui->actionMonitor_mode->setVisible(false); #endif diff --git a/bt_editor/mainwindow.h b/bt_editor/mainwindow.h index 3bdb2aeb..0bb39ba1 100644 --- a/bt_editor/mainwindow.h +++ b/bt_editor/mainwindow.h @@ -43,7 +43,12 @@ class MainWindow : public QMainWindow SUBTREE_REFRESH}; public: - explicit MainWindow(GraphicMode initial_mode, QWidget *parent = nullptr); + explicit MainWindow(GraphicMode initial_mode, + const QString& monitor_address = "", + const QString& monitor_pub_port = "", + const QString& monitor_srv_port = "", + const bool monitor_autoconnect = false, + QWidget *parent = nullptr); ~MainWindow() override; void loadFromXML(const QString &xml_text); @@ -202,7 +207,12 @@ private slots: #ifdef ZMQ_FOUND SidepanelMonitor* _monitor_widget; #endif - + + QString _monitor_address; + QString _monitor_publisher_port; + QString _monitor_server_port; + bool _monitor_autoconnect; + MainWindow::SavedState saveCurrentState(); void clearUndoStacks(); }; diff --git a/bt_editor/sidepanel_monitor.cpp b/bt_editor/sidepanel_monitor.cpp index 0efb560d..9164661d 100644 --- a/bt_editor/sidepanel_monitor.cpp +++ b/bt_editor/sidepanel_monitor.cpp @@ -10,7 +10,10 @@ #include "mainwindow.h" #include "utils.h" -SidepanelMonitor::SidepanelMonitor(QWidget *parent) : +SidepanelMonitor::SidepanelMonitor(QWidget *parent, + const QString &address, + const QString &publisher_port, + const QString &server_port) : QFrame(parent), ui(new Ui::SidepanelMonitor), _zmq_context(1), @@ -20,8 +23,22 @@ SidepanelMonitor::SidepanelMonitor(QWidget *parent) : _parent(parent) { ui->setupUi(this); - _timer = new QTimer(this); + this->set_load_tree_timeout_ms(_load_tree_default_timeout_ms); + if ( !address.isEmpty() ) + { + ui->lineEdit_address->setText(address); + } + if ( !publisher_port.isEmpty() ) + { + ui->lineEdit_publisher->setText(publisher_port); + } + if ( !server_port.isEmpty() ) + { + ui->lineEdit_server->setText(server_port); + } + + _timer = new QTimer(this); connect( _timer, &QTimer::timeout, this, &SidepanelMonitor::on_timer ); } @@ -97,7 +114,7 @@ void SidepanelMonitor::on_timer() qDebug() << "Reload tree from server"; if( !getTreeFromServer() ) { _connected = false; - ui->lineEdit->setDisabled(false); + ui->lineEdit_address->setDisabled(false); _timer->stop(); connectionUpdate(false); return; @@ -127,8 +144,7 @@ bool SidepanelMonitor::getTreeFromServer() zmq::socket_t zmq_client( _zmq_context, ZMQ_REQ ); zmq_client.connect( _connection_address_req.c_str() ); - int timeout_ms = 1000; - zmq_client.setsockopt(ZMQ_RCVTIMEO,&timeout_ms, sizeof(int) ); + zmq_client.setsockopt(ZMQ_RCVTIMEO, &_load_tree_timeout_ms, sizeof(int) ); zmq_client.send(request, zmq::send_flags::none); @@ -187,13 +203,13 @@ bool SidepanelMonitor::getTreeFromServer() void SidepanelMonitor::on_Connect() { - if( !_connected) + if( !_connected ) { - QString address = ui->lineEdit->text(); + QString address = ui->lineEdit_address->text(); if( address.isEmpty() ) { - address = ui->lineEdit->placeholderText(); - ui->lineEdit->setText(address); + address = ui->lineEdit_address->placeholderText(); + ui->lineEdit_address->setText(address); } QString publisher_port = ui->lineEdit_publisher->text(); @@ -221,13 +237,16 @@ void SidepanelMonitor::on_Connect() int timeout_ms = 1; _zmq_subscriber.setsockopt(ZMQ_SUBSCRIBE, "", 0); - _zmq_subscriber.setsockopt(ZMQ_RCVTIMEO,&timeout_ms, sizeof(int) ); + _zmq_subscriber.setsockopt(ZMQ_RCVTIMEO, &timeout_ms, sizeof(int) ); if( !getTreeFromServer() ) { failed = true; _connected = false; } + // After we try get a tree on connect, reset to the default timeout. + // This is done so that we only use the increased autoconnect timeout once. + this->set_load_tree_timeout_ms(_load_tree_default_timeout_ms); } catch(zmq::error_t& err) { @@ -241,9 +260,9 @@ void SidepanelMonitor::on_Connect() if( !failed ) { _connected = true; - ui->lineEdit->setDisabled(true); + ui->lineEdit_address->setDisabled(true); ui->lineEdit_publisher->setDisabled(true); - _timer->start(20); + _timer->start(_timer_period_ms); connectionUpdate(true); } else{ @@ -255,7 +274,7 @@ void SidepanelMonitor::on_Connect() } else{ _connected = false; - ui->lineEdit->setDisabled(false); + ui->lineEdit_address->setDisabled(false); ui->lineEdit_publisher->setDisabled(false); _timer->stop(); diff --git a/bt_editor/sidepanel_monitor.h b/bt_editor/sidepanel_monitor.h index 682cd1c5..5d16795f 100644 --- a/bt_editor/sidepanel_monitor.h +++ b/bt_editor/sidepanel_monitor.h @@ -15,11 +15,26 @@ class SidepanelMonitor : public QFrame Q_OBJECT public: - explicit SidepanelMonitor(QWidget *parent = nullptr); + /// Timer period in milliseconds. + static constexpr int _timer_period_ms = 20; + /// Default timeout to get behavior tree, in milliseconds. + static constexpr int _load_tree_default_timeout_ms = 1000; + /// Timeout to get behavior tree during autoconnect, in milliseconds. + static constexpr int _load_tree_autoconnect_timeout_ms = 10000; + + explicit SidepanelMonitor(QWidget *parent = nullptr, + const QString &address = "", + const QString &publisher_port = "", + const QString &server_port = ""); ~SidepanelMonitor(); void clear(); + void set_load_tree_timeout_ms(const int timeout_ms) + { + _load_tree_timeout_ms = timeout_ms; + }; + public slots: void on_Connect(); @@ -44,11 +59,14 @@ private slots: zmq::context_t _zmq_context; zmq::socket_t _zmq_subscriber; + QTimer* _timer; + bool _connected; std::string _connection_address_pub; std::string _connection_address_req; - QTimer* _timer; int _msg_count; + + int _load_tree_timeout_ms; // Timeout to get behavior tree. AbsBehaviorTree _loaded_tree; std::unordered_map _uid_to_index; diff --git a/bt_editor/sidepanel_monitor.ui b/bt_editor/sidepanel_monitor.ui index 37e58287..faad639f 100644 --- a/bt_editor/sidepanel_monitor.ui +++ b/bt_editor/sidepanel_monitor.ui @@ -39,7 +39,7 @@ - + 16777215 From f7fac396eaf84efa8eab8a91f335e343ec8ce25f Mon Sep 17 00:00:00 2001 From: Tim Clephas Date: Fri, 9 Jun 2023 17:37:28 +0200 Subject: [PATCH 24/28] Add button to save svg files (#186) --- bt_editor/graphic_container.cpp | 15 +++++++- bt_editor/graphic_container.h | 2 + bt_editor/mainwindow.cpp | 25 +++++++++++- bt_editor/mainwindow.h | 4 ++ bt_editor/mainwindow.ui | 68 ++++++++++++++++++++++++++++++++- 5 files changed, 109 insertions(+), 5 deletions(-) diff --git a/bt_editor/graphic_container.cpp b/bt_editor/graphic_container.cpp index 3dfce1b6..5a9872c2 100644 --- a/bt_editor/graphic_container.cpp +++ b/bt_editor/graphic_container.cpp @@ -11,6 +11,7 @@ #include #include #include +#include using namespace QtNodes; @@ -162,6 +163,18 @@ void GraphicContainer::nodeReorder() emit undoableChange(); } +void GraphicContainer::saveSvgFile(const QString path) +{ + QSvgGenerator generator; + QRectF rect = _scene->itemsBoundingRect(); + generator.setFileName(path); + generator.setSize(QSize(rect.width(), rect.height())); + generator.setViewBox(rect); + QPainter painter; + painter.begin(&generator); + _scene->render(&painter, rect, rect); +} + void GraphicContainer::zoomHomeView() { QRectF rect = _scene->itemsBoundingRect(); @@ -720,5 +733,3 @@ void GraphicContainer::loadFromJson(const QByteArray &data) clearScene(); scene()->loadFromMemory( data ); } - - diff --git a/bt_editor/graphic_container.h b/bt_editor/graphic_container.h index b725e8bf..eb3ee3c6 100644 --- a/bt_editor/graphic_container.h +++ b/bt_editor/graphic_container.h @@ -33,6 +33,8 @@ class GraphicContainer : public QObject void nodeReorder(); + void saveSvgFile(const QString path); + void zoomHomeView(); bool containsValidTree() const; diff --git a/bt_editor/mainwindow.cpp b/bt_editor/mainwindow.cpp index 865a5fae..56b02ba1 100644 --- a/bt_editor/mainwindow.cpp +++ b/bt_editor/mainwindow.cpp @@ -683,13 +683,30 @@ void MainWindow::onAutoArrange() currentTabInfo()->nodeReorder(); } +void MainWindow::onSaveSvg() +{ + QSettings settings; + QString last_load_path = settings.value("MainWindow.lastLoadDirectory", + QDir::homePath() ).toString(); + QString directory_path = settings.value("MainWindow.lastSaveSvgDirectory", + last_load_path ).toString(); + + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save BehaviorTree to svg"), directory_path, + tr("SVG files (*.svg)")); + currentTabInfo()->saveSvgFile(fileName); + + directory_path = QFileInfo(fileName).absolutePath(); + settings.setValue("SidepanelEditor.lastSaveSvgDirectory", directory_path); +} + void MainWindow::onSceneChanged() { const bool valid_BT = currentTabInfo()->containsValidTree(); ui->toolButtonLayout->setEnabled(valid_BT); ui->toolButtonReorder->setEnabled(valid_BT); - ui->toolButtonReorder->setEnabled(valid_BT); + ui->toolButtonSaveSvg->setEnabled(valid_BT); ui->actionSave->setEnabled(valid_BT); QPixmap pix; @@ -1167,6 +1184,11 @@ void MainWindow::on_toolButtonReorder_pressed() onAutoArrange(); } +void MainWindow::on_toolButtonSaveSvg_pressed() +{ + onSaveSvg(); +} + void MainWindow::on_toolButtonCenterView_pressed() { currentTabInfo()->zoomHomeView(); @@ -1313,6 +1335,7 @@ void MainWindow::updateCurrentMode() ui->toolButtonSaveFile->setHidden( NOT_EDITOR ); ui->toolButtonReorder->setHidden( NOT_EDITOR ); + ui->toolButtonSaveSvg->setHidden( NOT_EDITOR ); if( _current_mode == GraphicMode::EDITOR ) { diff --git a/bt_editor/mainwindow.h b/bt_editor/mainwindow.h index 0bb39ba1..56af8823 100644 --- a/bt_editor/mainwindow.h +++ b/bt_editor/mainwindow.h @@ -71,6 +71,8 @@ public slots: void onAutoArrange(); + void onSaveSvg(); + void onSceneChanged(); void onPushUndo(); @@ -102,6 +104,8 @@ public slots: void on_toolButtonReorder_pressed(); + void on_toolButtonSaveSvg_pressed(); + void on_toolButtonCenterView_pressed(); void onCreateAbsBehaviorTree(const AbsBehaviorTree &tree, diff --git a/bt_editor/mainwindow.ui b/bt_editor/mainwindow.ui index 80594ee2..8410449b 100644 --- a/bt_editor/mainwindow.ui +++ b/bt_editor/mainwindow.ui @@ -511,8 +511,7 @@ QToolButton:disabled{ true - - + false @@ -577,6 +576,71 @@ QToolButton:disabled{ + + + + false + + + + 80 + 70 + + + + + 80 + 70 + + + + + 9 + + + + Qt::NoFocus + + + QToolButton { + color:white; +} + +QToolButton:hover{ + background-color: rgb(110, 110, 110); +} + +QToolButton:pressed{ + background-color: rgb(50, 150, 0) +} + +QToolButton:disabled{ + color:gray; + background-color: rgb(50, 50, 50) +} + + + + Save svg + + + + :/icons/svg/save_white.svg:/icons/svg/save_white.svg + + + + 32 + 32 + + + + Qt::ToolButtonTextUnderIcon + + + true + + + From ca6c8f253f033bbdbe9294d1c9d0ac0beeb00241 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 10 Oct 2023 14:49:54 +0300 Subject: [PATCH 25/28] Simplify clone with recursion and use cmake for compile (#194) Signed-off-by: Ryan Friedman Co-authored-by: Ryan Friedman --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ff95c459..85a46e5b 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,10 @@ project is compiled with _catkin_. ## Compilation instructions (Linux) ``` -git clone https://github.com/BehaviorTree/Groot.git +git clone --recurse-submodules https://github.com/BehaviorTree/Groot.git cd Groot -git submodule update --init --recursive -mkdir build; cd build -cmake .. -make +cmake -S . -B build +cmake --build build ``` Note compiling "in-source" is not allowed. From 33a2fc41d2203d0809bff255f5f2f048c261666d Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 11 Feb 2024 00:23:07 +1100 Subject: [PATCH 26/28] Link with ncurses instead of curses (#200) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4de06bfb..eeda3eaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,7 @@ add_library(behavior_tree_editor SHARED ${FORMS_HEADERS} ) -SET(GROOT_DEPENDENCIES QtNodeEditor curses ncursesw tinfo ) +SET(GROOT_DEPENDENCIES QtNodeEditor ncurses ncursesw tinfo ) if(ament_cmake_FOUND) ament_target_dependencies(behavior_tree_editor ${dependencies}) From 66aee170c67517849b0ae5084e7cec01995eb349 Mon Sep 17 00:00:00 2001 From: Anton Kesy Date: Sat, 10 Feb 2024 14:23:20 +0100 Subject: [PATCH 27/28] fix typo (#197) --- bt_editor/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bt_editor/mainwindow.cpp b/bt_editor/mainwindow.cpp index 56b02ba1..3b135175 100644 --- a/bt_editor/mainwindow.cpp +++ b/bt_editor/mainwindow.cpp @@ -484,7 +484,7 @@ QString MainWindow::saveToXML() const if( abs_root->children_index.size() == 1 && abs_root->model.registration_ID == "Root" ) { - // mofe to the child of ROOT + // move to the child of ROOT abs_root = abs_tree.node( abs_root->children_index.front() ); } From 70973d004365f16d47a8c7bd9c5d84fa0bb9d05d Mon Sep 17 00:00:00 2001 From: Tim Clephas Date: Fri, 28 Feb 2025 19:01:01 +0100 Subject: [PATCH 28/28] Feature: Add commandline options of editor file and svg output (#187) * Add button to save svg files * Add cli for outputting svg --- bt_editor/main.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/bt_editor/main.cpp b/bt_editor/main.cpp index d80e92ee..ebc10458 100644 --- a/bt_editor/main.cpp +++ b/bt_editor/main.cpp @@ -56,6 +56,16 @@ main(int argc, char *argv[]) "Autoconnect to monitor"); parser.addOption(autoconnect_option); + QCommandLineOption file_option(QStringList() << "file", + "Load a file (only in editor mode)", + "tree.xml"); + parser.addOption(file_option); + + QCommandLineOption output_svg_option(QStringList() << "output-svg", + "Save the input file to an svg", + "output.svg"); + parser.addOption(output_svg_option); + parser.process( app ); QFile styleFile( ":/stylesheet.qss" ); @@ -92,7 +102,7 @@ main(int argc, char *argv[]) else{ std::cout << "wrong mode passed to --mode. Use on of these: editor / monitor /replay" << std::endl; - return 0; + return 1; } } else{ @@ -114,6 +124,52 @@ main(int argc, char *argv[]) // Start the main application. MainWindow win( mode, monitor_address, monitor_pub_port, monitor_srv_port, monitor_autoconnect ); + + if( parser.isSet(file_option) ) + { + if ( mode != GraphicMode::EDITOR ) + { + std::cout << "--file can only be passed in editor mode" << std::endl; + return 1; + } + + QString fileName = parser.value(file_option); + std::cout << "Loading file: " << fileName.toStdString() << std::endl; + + // Open file + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) + { + std::cout << "Cannot open file" << std::endl; + return 1; + } + + // Read file to xml + QString xml_text; + QTextStream in(&file); + while (!in.atEnd()) { + xml_text += in.readLine(); + } + + // Show xml + win.loadFromXML( xml_text ); + } + + + if( parser.isSet(output_svg_option) ) + { + if ( !parser.isSet(file_option)) + { + std::cout << "--output-svg needs the --file" << std::endl; + return 1; + } + QString svgFile = parser.value(output_svg_option); + + std::cout << "Writing to: " << svgFile.toStdString() << std::endl; + win.currentTabInfo()->saveSvgFile(svgFile); + return 0; + } + win.show(); return app.exec(); }