Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
igonzf authored Apr 11, 2024
2 parents d062822 + 28b1411 commit 68b2b8d
Show file tree
Hide file tree
Showing 74 changed files with 2,361 additions and 570 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: main

on:
pull_request:
branches:
- main
push:
branches:
- main
schedule:
- cron: '0 0 * * 6'
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
fail-fast: false
steps:
- name: Setup ROS 2
uses: ros-tooling/[email protected]
with:
required-ros-distributions: humble
- name: Install nlohmann
run: sudo apt -y install nlohmann-json3-dev
- name: build and test
uses: ros-tooling/[email protected]
with:
package-name: arm bt_test hri motion perception robocup_bringup cs4home_core
target-ros2-distro: humble
colcon-defaults: |
{
"test": {
"parallel-workers" : 1
}
}
vcs-repo-file-url: https://raw.githubusercontent.com/CoreSenseEU/CoreSense4Home/main/robocup_bringup/thirdparty.repos
3 changes: 3 additions & 0 deletions bt_nodes/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ include_directories(include)
add_library(pick_bt_node SHARED src/manipulation/pick_object.cpp)
list(APPEND plugin_libs pick_bt_node)

add_library(move_to_predefined_bt_node SHARED src/manipulation/move_to_predefined.cpp)
list(APPEND plugin_libs move_to_predefined_bt_node)

foreach(bt_plugin ${plugin_libs})
ament_target_dependencies(${bt_plugin} ${dependencies})
target_compile_definitions(${bt_plugin} PRIVATE BT_PLUGIN_EXPORT)
Expand Down
59 changes: 59 additions & 0 deletions bt_nodes/arm/include/arm/manipulation/move_to_predefined.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2024 Intelligent Robotics Lab - Gentlebots
//
// 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 andGO2OBJECT
// limitations under the License.

#ifndef ARM_MANIPULATION__MOVE_TO_PREDEFINED_HPP_
#define ARM_MANIPULATION__MOVE_TO_PREDEFINED_HPP_

#include <algorithm>
#include <string>

#include "manipulation_interfaces/action/move_to_predefined.hpp"
#include "moveit_msgs/msg/collision_object.hpp"
#include "behaviortree_cpp_v3/behavior_tree.h"
#include "behaviortree_cpp_v3/bt_factory.h"
#include "arm/manipulation/BTActionNode.hpp"
#include "rclcpp/rclcpp.hpp"

namespace manipulation
{

class MoveToPredefined : public manipulation::BtActionNode<manipulation_interfaces::action::MoveToPredefined>
{
public:
explicit MoveToPredefined(
const std::string & xml_tag_name,
const std::string & action_name,
const BT::NodeConfiguration & conf);

void on_tick() override;
BT::NodeStatus on_success() override;

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

private:
// rclcpp::Node::SharedPtr node_;
// rclcpp::ActionClient<audio_common_msgs::action::TTS>::SharedPtr
// tts_action_;

std::string pose_;
};

} // namespace manipulation

#endif // ARM_MANIPULATION__MOVE_TO_PREDEFINED_HPP_
55 changes: 55 additions & 0 deletions bt_nodes/arm/src/manipulation/move_to_predefined.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2024 Intelligent Robotics Lab - Gentlebots
//
// 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 <string>
#include <utility>

#include "arm/manipulation/move_to_predefined.hpp"
#include "manipulation_interfaces/action/move_to_predefined.hpp"
#include "behaviortree_cpp_v3/behavior_tree.h"

namespace manipulation
{

using namespace std::chrono_literals;
using namespace std::placeholders;

MoveToPredefined::MoveToPredefined(
const std::string & xml_tag_name, const std::string & action_name,
const BT::NodeConfiguration & conf)
: manipulation::BtActionNode<manipulation_interfaces::action::MoveToPredefined>(xml_tag_name,
action_name, conf) {}

void MoveToPredefined::on_tick()
{

RCLCPP_DEBUG(node_->get_logger(), "MoveToPredefined ticked");

getInput("pose", pose_);
goal_.group_name = "arm_torso";
goal_.goal_pose = pose_;
}

BT::NodeStatus MoveToPredefined::on_success() {return BT::NodeStatus::SUCCESS;}

} // namespace manipulation
#include "behaviortree_cpp_v3/bt_factory.h"
BT_REGISTER_NODES(factory) {
BT::NodeBuilder builder = [](const std::string & name,
const BT::NodeConfiguration & config) {
return std::make_unique<manipulation::MoveToPredefined>(name, "/move_to_predefined", config);
};

factory.registerBuilder<manipulation::MoveToPredefined>("MoveToPredefined", builder);
}
2 changes: 1 addition & 1 deletion bt_nodes/arm/src/manipulation/pick_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PickObject::PickObject(
void PickObject::on_tick()
{

RCLCPP_DEBUG(node_->get_logger(), "Speak ticked");
RCLCPP_DEBUG(node_->get_logger(), "PickObject ticked");
moveit_msgs::msg::CollisionObject::SharedPtr object_;
getInput("object_to_pick", object_);
goal_.object_goal = *object_;
Expand Down
42 changes: 36 additions & 6 deletions bt_nodes/bt_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ find_package(perception REQUIRED)
find_package(arm REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(hri REQUIRED)
find_package(perception_system_interfaces REQUIRED)

set(CMAKE_CXX_STANDARD 17)

Expand All @@ -38,6 +39,7 @@ set(dependencies
hri
arm
geometry_msgs
perception_system_interfaces
)

# Set WP test
Expand Down Expand Up @@ -107,18 +109,44 @@ target_link_libraries(generate_text_from_objects_test hri::generate_text_from_ob
# pick_demo test
add_executable(pick_demo_test src/pick_demo_test.cpp)
ament_target_dependencies(pick_demo_test ${dependencies})
target_link_libraries(pick_demo_test arm::pick_bt_node hri::generate_text_from_objects_bt_node perception::extract_object_from_scene_bt_node hri::speak_bt_node hri::dialogConfirmation_bt_node)

# follow_person test
add_executable(follow_person_test src/follow_person_test.cpp)
ament_target_dependencies(follow_person_test ${dependencies})
target_link_libraries(follow_person_test perception::follow_person_bt_node)
target_link_libraries(pick_demo_test
arm::pick_bt_node
hri::generate_text_from_objects_bt_node
perception::extract_object_from_scene_bt_node
perception::extract_collision_scene_bt_node
hri::speak_bt_node
hri::dialogConfirmation_bt_node
)

# Ask test
add_executable(ask_test src/ask_test.cpp)
ament_target_dependencies(ask_test ${dependencies})
target_link_libraries(ask_test hri::query_bt_node hri::speak_bt_node hri::listen_bt_node hri::dialogConfirmation_bt_node)

# init_carry test
add_executable(init_carry src/init_carry_test.cpp)
ament_target_dependencies(init_carry ${dependencies})
target_link_libraries(configuration::init_carry_bt_node)

# follow_person test
add_executable(follow_person_test src/follow_person_test.cpp)
ament_target_dependencies(follow_person_test ${dependencies})
target_link_libraries(follow_person_test perception::follow_person_bt_node)

# carry my luggage test
add_executable(carry_my_luggage_test src/carry_my_luggage_test.cpp)
ament_target_dependencies(carry_my_luggage_test ${dependencies})
target_link_libraries(carry_my_luggage_test
configuration::init_carry_bt_node
perception::is_detected_bt_node
perception::is_pointing_bt_node
perception::is_entity_moving_bt_node
arm::move_to_predefined_bt_node
motion::move_to_bt_node
motion::look_at_bt_node
hri::speak_bt_node
hri::dialogConfirmation_bt_node
)

install(TARGETS
set_wp_test
Expand All @@ -137,6 +165,8 @@ install(TARGETS
generate_text_from_objects_test
pick_demo_test
follow_person_test
init_carry
carry_my_luggage_test
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
Expand Down
102 changes: 102 additions & 0 deletions bt_nodes/bt_test/bt_xml/carry_my_luggage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0"?>
<root main_tree_to_execute="BehaviorTree">
<!-- ////////// -->
<BehaviorTree ID="BehaviorTree">
<Sequence>
<Action ID="InitCarry"/>
<RetryUntilSuccessful num_attempts="-1">
<Sequence>
<Condition ID="IsDetected" cam_frame="head_front_camera_link_color_optical_frame" confidence="0.6" frames="{frames}" interest="person" max_depth="3" max_entities="1" order="color"/>
<Condition ID="IsPointing" bag_frame="{bag_tf}" cam_frame="head_front_camera_link_color_optical_frame"/>
</Sequence>
</RetryUntilSuccessful>
<RetryUntilSuccessful num_attempts="-1">
<Action ID="MoveTo" distance_tolerance="1.0" tf_frame="{bag_tf}" will_finish="true"/>
</RetryUntilSuccessful>
<Action ID="MoveToPredefined" pose="offer"/>
<ReactiveSequence>
<Action ID="LookAt" tf_frame="person_0" tf_frames=""/>
<Action ID="Speak" param="" say_text="please put the bag in my gripper"/>
</ReactiveSequence>
<Repeat num_cycles="5">
<Action ID="LookAt" tf_frame="gripper_link" tf_frames=""/>
</Repeat>
<Delay delay_msec="5000">
<Action ID="MoveToPredefined" pose="home"/>
</Delay>
<ReactiveSequence>
<Action ID="LookAt" tf_frame="person_0" tf_frames=""/>
<Action ID="Speak" param="" say_text="Perfect, now i will follow you. Please stop at the end "/>
</ReactiveSequence>
<RetryUntilSuccessful num_attempts="-1">
<Fallback>
<ReactiveSequence>
<RetryUntilSuccessful num_attempts="-1">
<Condition ID="IsDetected" cam_frame="head_front_camera_link_color_optical_frame" confidence="0.3" frames="" interest="person" max_depth="6" max_entities="1" order="color"/>
</RetryUntilSuccessful>
<Action ID="LookAt" tf_frame="person_0"/>
<Condition ID="IsEntityMoving" velocity_tolerance="0.12" frame="person_0" max_iterations="100"/>
<Action ID="MoveTo" distance_tolerance="0.2" tf_frame="person_0" will_finish="false"/>
</ReactiveSequence>
<ForceFailure>
<Action ID="Speak" param="" say_text="have we arrived to the destination?"/>
</ForceFailure>
<Action ID="DialogConfirmation"/>
</Fallback>
</RetryUntilSuccessful>
<Action ID="MoveToPredefined" pose="offer"/>
<ReactiveSequence>
<Action ID="LookAt" tf_frame="person_0" tf_frames=""/>
<Action ID="Speak" param="" say_text="Here is the bag, please take it"/>
</ReactiveSequence>
<Action ID="LookAt" tf_frame="gripper_link"/>
<Action ID="MoveToPredefined" pose="home"/>
<Delay delay_msec="3000">
<Action ID="Speak" param="" say_text="I am going back, have a nice day"/>
</Delay>
<Action ID="MoveTo" distance_tolerance="0.0" tf_frame="odom"/>
</Sequence>
</BehaviorTree>
<!-- ////////// -->
<TreeNodesModel>
<Action ID="DialogConfirmation"/>
<Action ID="InitCarry"/>
<Condition ID="IsDetected">
<input_port default="head_front_camera_link_color_optical_frame" name="cam_frame"/>
<input_port default="0.6" name="confidence"/>
<output_port name="frames">array of frames</output_port>
<input_port default="person" name="interest"/>
<input_port default="2" name="max_depth">value in meters</input_port>
<input_port default="1" name="max_entities"/>
<input_port default="depth_nearest" name="order">[depth, color]</input_port>
</Condition>
<Condition ID="IsEntityMoving">
<input_port name="check_time"/>
<input_port name="distance_tolerance"/>
<input_port name="frame"/>
</Condition>
<Condition ID="IsPointing">
<output_port name="bag_frame"/>
<input_port name="cam_frame"/>
</Condition>
<Action ID="Listen">
<output_port name="listen_text"/>
</Action>
<Action ID="LookAt">
<input_port name="tf_frame"/>
<input_port name="tf_frames"/>
</Action>
<Action ID="MoveTo">
<input_port default="1.0" name="distance_tolerance"/>
<input_port name="tf_frame"/>
</Action>
<Action ID="MoveToPredefined">
<input_port default="offer" name="pose"/>
</Action>
<Action ID="Speak">
<input_port name="param"/>
<input_port name="say_text"/>
</Action>
</TreeNodesModel>
<!-- ////////// -->
</root>
5 changes: 3 additions & 2 deletions bt_nodes/bt_test/bt_xml/follow_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<root main_tree_to_execute="BehaviorTree">
<!-- ////////// -->
<BehaviorTree ID="BehaviorTree">
<Repeat num_cycles="20">
<RetryUntilSuccessful num_attempts="-1">
<ReactiveSequence>
<Condition ID="IsDetected" confidence="0.6" entity="person" frames="" max_depth="2" max_entities="1" order="depth_nearest"/>
<Action ID ="LookAt" tf_frame="person"/>
<Action ID="MoveTo" tf_frame="person"/>
</ReactiveSequence>
</Repeat>
</RetryUntilSuccessful>
</BehaviorTree>
<!-- ////////// -->
<TreeNodesModel>
Expand All @@ -22,6 +22,7 @@
</Condition>
<Action ID="LookAt">
<input_port default="person" name="tf_frame"/>
</Action>
<Action ID="MoveTo">
<input_port default="person" name="tf_frame"/>
</Action>
Expand Down
12 changes: 12 additions & 0 deletions bt_nodes/bt_test/bt_xml/init_carry_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<root main_tree_to_execute="BehaviorTree">
<!-- ////////// -->
<BehaviorTree ID="BehaviorTree">
<Action ID="InitCarry"/>
</BehaviorTree>
<!-- ////////// -->
<TreeNodesModel>
<Action ID="InitCarry"/>
</TreeNodesModel>
<!-- ////////// -->
</root>
Loading

0 comments on commit 68b2b8d

Please sign in to comment.