Skip to content

Commit

Permalink
More setup
Browse files Browse the repository at this point in the history
  • Loading branch information
andyblarblar committed Nov 8, 2023
1 parent 0cb7b93 commit 5256704
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(phnx_msgs REQUIRED)
find_package(OpenCV 4.2.0 REQUIRED)

# Add source for node executable (link non-ros dependencies here)
add_executable(obj_tracker src/ObjTrackerNode.cpp src/ObjTrackerNode_node.cpp)
Expand All @@ -26,6 +27,7 @@ set(dependencies
geometry_msgs
nav_msgs
phnx_msgs
OpenCV
)

# Link ros dependencies
Expand Down
12 changes: 7 additions & 5 deletions include/obj_tracker/ObjTrackerNode_node.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#pragma once

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
#include "geometry_msgs/msg/pose_array.hpp"

class ObjTrackerNode : public rclcpp::Node {
private:
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub;
/// Filtered poses
rclcpp::Publisher<geometry_msgs::msg::PoseArray>::SharedPtr pose_pub;

rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub;
/// Poses to be filtered
rclcpp::Subscription<geometry_msgs::msg::PoseArray>::SharedPtr pose_sub;

public:
ObjTrackerNode(const rclcpp::NodeOptions& options);

/// subscriber callback
void sub_cb(std_msgs::msg::String::SharedPtr msg);
/// Pose input
void pose_cb(geometry_msgs::msg::PoseArray::SharedPtr msg);
};
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>libopencv-dev</depend>
<depend>geometry_msgs</depend>
<depend>nav_msgs</depend>
<depend>phnx_msgs</depend>
Expand Down
22 changes: 4 additions & 18 deletions src/ObjTrackerNode_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,10 @@
using namespace std::placeholders;

ObjTrackerNode::ObjTrackerNode(const rclcpp::NodeOptions& options) : Node("ObjTrackerNode", options) {
// Parameters
float x = this->declare_parameter<float>("foo", -10.0);

// Pub Sub
this->sub =
this->create_subscription<std_msgs::msg::String>("/str", 1, std::bind(&ObjTrackerNode::sub_cb, this, _1));
this->pub = this->create_publisher<std_msgs::msg::String>("/run_folder", 1);

// Log a sample log
RCLCPP_INFO(this->get_logger(), "You passed %f", x);

// Send a sample message
std_msgs::msg::String msg{};
msg.data = std::string{"Hello World!"};
pub->publish(msg);
this->pose_sub = this->create_subscription<geometry_msgs::msg::PoseArray>(
"/object_poses", 10, std::bind(&ObjTrackerNode::pose_cb, this, _1));
this->pose_pub = this->create_publisher<geometry_msgs::msg::PoseArray>("/tracks", 1);
}

void ObjTrackerNode::sub_cb(const std_msgs::msg::String::SharedPtr msg) {
// Echo message
this->pub->publish(*msg);
}
void ObjTrackerNode::pose_cb(geometry_msgs::msg::PoseArray::SharedPtr msg) {}

0 comments on commit 5256704

Please sign in to comment.