Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
26280fc
hri nodes
rodperex Nov 13, 2024
26f5a9d
DialogConfirmation refined
rodperex Nov 14, 2024
5421d5f
Navigation bt nodes refined + one added
rodperex Nov 14, 2024
4dc79c1
minor
rodperex Nov 14, 2024
d2d2456
navigation nodes refined
rodperex Nov 18, 2024
0cc7f15
refined
rodperex Nov 19, 2024
3bfb8e3
perception
rodperex Nov 19, 2024
16f6ac5
motion nodes refined
rodperex Nov 19, 2024
41b0d7c
readme
rodperex Nov 19, 2024
c93136c
enhancements
rodperex Nov 21, 2024
8b951c6
additions to test
rodperex Nov 21, 2024
286db63
removed unnecessary dependency
rodperex Nov 22, 2024
d2f038d
dependency out
rodperex Nov 22, 2024
a4302b6
refined xml
rodperex Nov 22, 2024
e463163
DialogConfirmation tested
rodperex Nov 25, 2024
ec94f4d
Ignore things
rodperex Nov 25, 2024
ac81dee
minor
rodperex Nov 25, 2024
162cf2f
updated
rodperex Nov 25, 2024
eef850c
correction
rodperex Nov 25, 2024
c7ff86d
minor
rodperex Nov 25, 2024
1a4c2f5
refined
rodperex Nov 26, 2024
1559195
fix
rodperex Nov 27, 2024
4dda2f6
Needed parameter added
rodperex Nov 27, 2024
d20fa12
package refined
rodperex Nov 27, 2024
35a479f
IsPointing updated due to problems in real robot
rodperex Nov 28, 2024
113a426
minor
rodperex Nov 28, 2024
8009cf1
refined
rodperex Nov 28, 2024
d382785
IsPointing working in simulation
rodperex Nov 30, 2024
0beed0e
IsDetected cleaned
rodperex Nov 30, 2024
2c21d91
Detection as pointer in bb
rodperex Dec 2, 2024
19692e2
IsPointing uptated
rodperex Dec 2, 2024
8c73116
refined
rodperex Dec 3, 2024
8d695d5
XML adapted to new perception nodes
rodperex Dec 3, 2024
0a15e79
exlude _*.xml
rodperex Dec 3, 2024
4a519dd
minor
rodperex Dec 3, 2024
741bb02
N
rodperex Dec 4, 2024
e0083c3
unnecesary port
rodperex Dec 5, 2024
b0ddf1a
minor
rodperex Dec 9, 2024
414b97e
minor
rodperex Dec 9, 2024
d7f109a
minor
rodperex Dec 12, 2024
2545293
new BT node added
rodperex Dec 12, 2024
2d48361
xml
rodperex Dec 12, 2024
3596173
refined
rodperex Dec 12, 2024
f39da9d
minor
rodperex Dec 12, 2024
0a5bdb5
attention nodes untested
rodperex Dec 12, 2024
e0774d8
nodes
rodperex Dec 13, 2024
c664425
errors corrected
rodperex Dec 13, 2024
866c75d
errors corrected
rodperex Dec 13, 2024
71e127f
fixed
rodperex Jan 13, 2025
eaf9485
logging
rodperex Jan 13, 2025
c4464fc
provisional till get_by_id works
rodperex Jan 13, 2025
ce3ac64
logging
rodperex Mar 5, 2025
e83be5e
logging
rodperex Mar 5, 2025
b564788
logging
rodperex Mar 5, 2025
6001e38
update
rodperex Mar 5, 2025
e39457f
launch
rodperex May 5, 2025
fc19119
minor
rodperex May 6, 2025
9675117
bug
rodperex May 6, 2025
d00d552
tp
rodperex May 21, 2025
3bcd69a
minor
rodperex May 21, 2025
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitingore
_*.hpp
_*.cpp
_*.txt
_*.xml
63 changes: 63 additions & 0 deletions attention/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.8)
project(attention_bt_nodes)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_cascade_lifecycle REQUIRED)
find_package(attention_system REQUIRED)
find_package(behaviortree_cpp_v3 REQUIRED)

set(CMAKE_CXX_STANDARD 17)

set(dependencies
ament_index_cpp
rclcpp
rclcpp_cascade_lifecycle
attention_system
behaviortree_cpp_v3
)

include_directories(include)

set(plugin_sources
src/attention/activate_attention.cpp
src/attention/deactivate_attention.cpp
)

set(plugin_libs "")

foreach(src ${plugin_sources})
get_filename_component(plugin ${src} NAME_WE)
add_library(${plugin}_bt_node SHARED ${src})
ament_target_dependencies(${plugin}_bt_node ${dependencies})
target_compile_definitions(${plugin}_bt_node PRIVATE BT_PLUGIN_EXPORT)
list(APPEND plugin_libs ${plugin}_bt_node)
endforeach()

add_executable(attention_test src/main_attention.cpp)
ament_target_dependencies(attention_test ${dependencies})

install(TARGETS
attention_test
${plugin_libs}
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include launch config bt_xml
DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
2 changes: 2 additions & 0 deletions attention/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# perception_bt_nodes
A collection of BT nodes for perception capabilities
26 changes: 26 additions & 0 deletions attention/bt_xml/attend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<root main_tree_to_execute="BehaviorTree">
<!-- ////////// -->
<BehaviorTree ID="BehaviorTree">
<Sequence>
<Action ID="ActivateAttention" frame_id="person_1" what="base"/>
<Timeout msec="10000">
<RetryUntilSuccessful num_attempts="-1">
<AlwaysFailure/>
</RetryUntilSuccessful>
</Timeout>
<Action ID="DeactivateAttention" what="base"/>
</Sequence>
</BehaviorTree>
<!-- ////////// -->
<TreeNodesModel>
<Action ID="ActivateAttention">
<input_port name="frame_id"/>
<input_port default="base" name="what"/>
</Action>
<Action ID="DeactivateAttention">
<input_port default="base" name="what"/>
</Action>
</TreeNodesModel>
<!-- ////////// -->
</root>
7 changes: 7 additions & 0 deletions attention/config/attention.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
attention_node:
ros__parameters:
use_sim_time: True
bt_xml_file: attend.xml
plugins:
- activate_attention_bt_node
- deactivate_attention_bt_node
60 changes: 60 additions & 0 deletions attention/include/attention/activate_attention.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2024 Intelligent Robotics Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ATTENTION_ACTIVATE__HPP_
#define ATTENTION_ACTIVATE__HPP_

#include <memory>
#include <string>
#include <chrono>

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_cascade_lifecycle/rclcpp_cascade_lifecycle.hpp"
#include "behaviortree_cpp_v3/behavior_tree.h"
#include "behaviortree_cpp_v3/bt_factory.h"
#include "std_msgs/msg/string.hpp"


namespace attention
{

class ActivateAttention : public BT::ActionNodeBase
{
public:
explicit ActivateAttention(const std::string & xml_tag_name, const BT::NodeConfiguration & conf);

BT::NodeStatus tick();
void halt();

static BT::PortsList providedPorts()
{
return BT::PortsList(
{
BT::InputPort<std::string>("what"),
BT::InputPort<std::string>("frame_id"),
});
}

private:
std::shared_ptr<rclcpp_cascade_lifecycle::CascadeLifecycleNode> node_;

std::string frame_id_, what_;

rclcpp_lifecycle::LifecyclePublisher<std_msgs::msg::String>::SharedPtr attention_pub_;

};

} // namespace attention

#endif // ATTENTION_ACTIVATE__HPP_
58 changes: 58 additions & 0 deletions attention/include/attention/deactivate_attention.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2024 Intelligent Robotics Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ATTENTION_DEACTIVATE__HPP_
#define ATTENTION_DEACTIVATE__HPP_

#include <memory>
#include <string>
#include <chrono>

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_cascade_lifecycle/rclcpp_cascade_lifecycle.hpp"
#include "behaviortree_cpp_v3/behavior_tree.h"
#include "behaviortree_cpp_v3/bt_factory.h"
#include "std_msgs/msg/string.hpp"

namespace attention
{

class DeactivateAttention : public BT::ActionNodeBase
{
public:
explicit DeactivateAttention(const std::string & xml_tag_name, const BT::NodeConfiguration & conf);

BT::NodeStatus tick();
void halt();

static BT::PortsList providedPorts()
{
return BT::PortsList(
{
BT::InputPort<std::string>("what")
});
}

private:
std::shared_ptr<rclcpp_cascade_lifecycle::CascadeLifecycleNode> node_;

std::string what_;

rclcpp_lifecycle::LifecyclePublisher<std_msgs::msg::String>::SharedPtr attention_pub_;

};

} // namespace attention

#endif // ATTENTION_DEACTIVATE__HPP_
48 changes: 48 additions & 0 deletions attention/launch/attention.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2023 Rodrigo Pérez-Rodríguez
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
import yaml

def generate_launch_description():
# Get the launch directory
pkg_dir = get_package_share_directory('attention_bt_nodes')

params_file = os.path.join(pkg_dir, 'config', 'attention.yaml')
with open(params_file, 'r') as f:
params = yaml.safe_load(f)['attention_node']['ros__parameters']

ld = LaunchDescription()

nav_cmd = Node(
package='attention_bt_nodes',
executable='attention_test',
output='screen',
remappings=[
],
parameters=[{
'use_sim_time': True,
}, params]
)

ld.add_action(nav_cmd)

return ld

25 changes: 25 additions & 0 deletions attention/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>attention_bt_nodes</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="rodrigo.perez@urjc.es">rod</maintainer>

<license>Apache License, Version 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>

<depend>rclcpp</depend>
<depend>rclcpp_cascade_lifecycle</depend>
<depend>behaviortree_cpp_v3</depend>


<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
62 changes: 62 additions & 0 deletions attention/src/attention/activate_attention.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2024 Intelligent Robotics Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "attention/activate_attention.hpp"

namespace attention
{


ActivateAttention::ActivateAttention(const std::string & xml_tag_name, const BT::NodeConfiguration & conf)
: BT::ActionNodeBase(xml_tag_name, conf)
{
std::string what;

config().blackboard->get("node", node_);

getInput("frame_id", frame_id_);
getInput("what", what);
if (what == "base") {
node_->add_activation("attention_system_base");
} else {
RCLCPP_ERROR(node_->get_logger(), "Unknown what: %s. Activating generic", what.c_str());
node_->add_activation("attention_system_base");
}

attention_pub_ = node_->create_publisher<std_msgs::msg::String>("attention_system", 10);
attention_pub_->on_activate();
}
BT::NodeStatus ActivateAttention::tick()
{
RCLCPP_DEBUG(node_->get_logger(), "ACTIVATE_ATTENTION");

std_msgs::msg::String msg;
msg.data = frame_id_;
attention_pub_->publish(msg);

rclcpp::spin_some(node_->get_node_base_interface());

return BT::NodeStatus::SUCCESS;
}

void ActivateAttention::halt()
{
attention_pub_->on_deactivate();
}

} // namespace attention

BT_REGISTER_NODES(factory) {
factory.registerNodeType<attention::ActivateAttention>("ActivateAttention");
}
Loading