Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/bringup #25

Merged
merged 3 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions yacyac_bringup/launch/robot_description.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def generate_launch_description():
)

# # tracer mini package
# yacyac_camera_prefix = get_package_share_directory("yacyac_camera")
# start_yacyac_camera_cmd = IncludeLaunchDescription(
# PythonLaunchDescriptionSource(os.path.join(yacyac_camera_prefix, "launch", "camera.launch.py"))
# )
yacyac_camera_prefix = get_package_share_directory("yacyac_camera")
start_yacyac_camera_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(yacyac_camera_prefix, "launch", "camera.launch.py"))
)

# # rosbridge websocket cmd
# start_web_bridge_cmd = ExecuteProcess(
# cmd=["ros2", "launch", "rosbridge_server", "rosbridge_websocket_launch.xml"], output="screen"
# )
start_web_bridge_cmd = ExecuteProcess(
cmd=["ros2", "launch", "rosbridge_server", "rosbridge_websocket_launch.xml"], output="screen"
)

# start_insta360_cmd = ExecuteProcess(
# cmd=["ros2", "run", "insta360_node", "insta360_node"], output="screen"
Expand Down Expand Up @@ -81,7 +81,7 @@ def generate_launch_description():
base_to_imu_publisher,
start_g2lidar_cmd,
start_yacyac_cmd,
# start_web_bridge_cmd,
# start_yacyac_camera_cmd
start_web_bridge_cmd,
start_yacyac_camera_cmd
]
)
2 changes: 1 addition & 1 deletion yacyac_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ set(DEPENDENCIES
rclcpp_action
std_msgs
geometry_msgs
nav2_behavior_tree
nav2_msgs
behaviortree_cpp
nav2_behavior_tree
yacyac_interface
${OTHER_DEPS}
)
Expand Down
3 changes: 1 addition & 2 deletions yacyac_core/bt_xml/bt_nav_yac_supply.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<root BTCPP_format="4"
main_tree_to_execute="MainTree">
<root BTCPP_format="4" main_tree_to_execute="MainTree">
<BehaviorTree ID="Init">
<Sequence>
<SetBlackboard value="-0.579;-1.341;0.0;1.0"
Expand Down
2 changes: 2 additions & 0 deletions yacyac_core/include/yacyac_core/qr_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define QR_CLIENT_HPP_

#include <behaviortree_cpp/behavior_tree.h>
#include <std_msgs/msg/int8.hpp>
#include <rclcpp/rclcpp.hpp>

#include "yacyac_interface/msg/qrcode.hpp"
Expand All @@ -25,6 +26,7 @@ class QRClient : public BT::StatefulActionNode {
private:
rclcpp::Node::SharedPtr node_;
rclcpp::Subscription<yacyac_interface::msg::Qrcode>::SharedPtr qr_sub_;
rclcpp::Publisher<std_msgs::msg::Int8>::SharedPtr mode_publisher_;
double deadline_;
std::vector<std::string> detected_QR_;

Expand Down
10 changes: 10 additions & 0 deletions yacyac_core/src/nav2_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "tf2/LinearMath/Quaternion.h"
#include "tf2/transform_datatypes.h"
#include "tf2_geometry_msgs/tf2_geometry_msgs.h"
#include <std_msgs/msg/int8.hpp>

// Custom type
struct Pose2D {
Expand Down Expand Up @@ -56,8 +57,17 @@ class Nav2Client : public BT::SyncActionNode {
virtual BT::NodeStatus tick() override
{
std::cout << "nav2 client tick" << std::endl;
const std::string mode_topic_name = "/mode";

node_ = rclcpp::Node::make_shared("nav2_client");
auto action_client = rclcpp_action::create_client<nav2_msgs::action::NavigateToPose>(node_, "navigate_to_pose");

auto mode_publisher = node_->create_publisher<std_msgs::msg::Int8>(mode_topic_name, rclcpp::QoS(1).best_effort());

auto message = std_msgs::msg::Int8();
message.data = 1;

mode_publisher->publish(message);
// if no server is present, fail after 5 seconds
std::cout << "nav2 server wait" << std::endl;
if (!action_client->wait_for_action_server(std::chrono::seconds(20))) {
Expand Down
11 changes: 9 additions & 2 deletions yacyac_core/src/qr_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
QRClient::QRClient(const std::string& name, const BT::NodeConfig& config) : BT::StatefulActionNode(name, config)
{
node_ = rclcpp::Node::make_shared("qr_client");
std::string QR_topic_name = "/qr_codes";
const std::string QR_topic_name = "/qr_codes";
const std::string mode_topic_name = "/mode";
node_->create_subscription<yacyac_interface::msg::Qrcode>(QR_topic_name, rclcpp::QoS(1), std::bind(&QRClient::QR_callback_, this, std::placeholders::_1));

mode_publisher_ = node_->create_publisher<std_msgs::msg::Int8>(mode_topic_name, rclcpp::QoS(1).best_effort());
}

QRClient::~QRClient()
Expand All @@ -14,9 +17,13 @@ QRClient::~QRClient()

BT::NodeStatus QRClient::onStart()
{
double life_time = rclcpp::Duration(10, 0).seconds();
double life_time = rclcpp::Duration(30, 0).seconds();
deadline_ = node_->get_clock()->now().seconds() + life_time;

auto message = std_msgs::msg::Int8();
message.data = 1;
mode_publisher_->publish(message);

return BT::NodeStatus::RUNNING;
}

Expand Down
Loading