Add drone control node
This commit is contained in:
parent
4c6a0b9478
commit
d44ac1a76c
2 changed files with 43 additions and 0 deletions
|
@ -28,6 +28,7 @@ catkin_package(CATKIN_DEPENDS
|
|||
include_directories (${catkin_INCLUDE_DIRS})
|
||||
|
||||
add_executable (papillon src/papillon.cpp)
|
||||
add_executable (control src/control.cpp)
|
||||
target_link_libraries(papillon ${catkin_LIBRARIES})
|
||||
set_property (TARGET papillon APPEND PROPERTY INCLUDE_DIRECTORIES ${OpenCV_INCLUDE_DIRS})
|
||||
set_property (TARGET papillon APPEND PROPERTY INCLUDE_DIRECTORIES ${catkin_INCLUDE_DIRS})
|
||||
|
|
42
src/control.cpp
Normal file
42
src/control.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include "ros/ros.h"
|
||||
#include <papillon/BoundingBox.h>
|
||||
#include <geometry_msgs/Twist.h>
|
||||
|
||||
#include <opencv/cv.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Drone_control {
|
||||
public:
|
||||
cv::Rect objectBoundingRectangle = cv::Rect(0,0,0,0);
|
||||
|
||||
ros::NodeHandle n;
|
||||
|
||||
ros::Publisher pub_cmd;
|
||||
ros::Subscriber sub_box;
|
||||
|
||||
|
||||
Drone_control() : n("~") {
|
||||
pub_cmd = n.advertise<geometry_msgs::Twist>("/bebop/cmd_vel", 1);
|
||||
sub_box = n.subscribe<papillon::BoundingBox>("/papillon/bbox", 1, &Drone_control::on_msg, this);
|
||||
}
|
||||
|
||||
|
||||
// This processes an image and publishes the result.
|
||||
void on_msg(const papillon::BoundingBox::ConstPtr& bbox) {
|
||||
ROS_INFO("plop");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ros::init(argc, argv, "control");
|
||||
Drone_control con=Drone_control();
|
||||
ros::spin();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in a new issue