Browse Source

Add drone control node

master
lhark 10 years ago
parent
commit
d44ac1a76c
  1. 1
      CMakeLists.txt
  2. 42
      src/control.cpp

1
CMakeLists.txt

@ -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

@ -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…
Cancel
Save