1 #include <geometry_msgs/PoseStamped.h>
2 #include <geometry_msgs/TwistStamped.h>
5 #include <std_msgs/Int8.h>
12 #include <visp_ros/BlobTracker.h>
14 #include <visp3/core/vpCameraParameters.h>
15 #include <visp3/core/vpHomogeneousMatrix.h>
16 #include <visp3/core/vpImageConvert.h>
17 #include <visp3/gui/vpDisplayGDI.h>
18 #include <visp3/gui/vpDisplayOpenCV.h>
19 #include <visp3/gui/vpDisplayX.h>
20 #include <visp3/visual_features/vpFeatureThetaU.h>
21 #include <visp3/visual_features/vpFeatureTranslation.h>
22 #include <visp3/vs/vpAdaptiveGain.h>
23 #include <visp3/vs/vpServo.h>
62 #elif defined( VISP_HAVE_GDI )
64 #elif defined( VISP_HAVE_OPENCV )
76 void display(
const visp_ros::BlobTracker::ConstPtr &msg );
77 void data_callback(
const visp_ros::BlobTracker::ConstPtr &msg );
80 VS(
int argc,
char **argv );
106 , m_square_size( 0.12 )
145 ROS_ERROR(
"Camera parameters are not set" );
159 std::cout <<
"Desired pose: " <<
m_cdMo << std::endl;
167 m_task.setServo( vpServo::EYEINHAND_CAMERA );
168 m_task.setInteractionMatrixType( vpServo::CURRENT );
183 #elif VISP_HAVE_OPENCV
189 std::cout <<
"Camera parameters:\n" <<
m_cam << std::endl;
200 cv::Mat cv_frame = cv_image_ptr->image;
210 std::vector< vpImagePoint > ips;
211 for (
unsigned int i = 0; i < msg->blob_cogs.size(); i++ )
213 vpImagePoint ip( msg->blob_cogs[i].i, msg->blob_cogs[i].j );
215 std::stringstream ss;
217 vpDisplay::displayText(
m_I_grayscale, ip + vpImagePoint( -20, 20 ), ss.str(), vpColor::red );
238 ROS_ERROR(
"cv_bridge exception: %s", e.what() );
246 geometry_msgs::TwistStamped camvel_msg;
254 std::ostringstream strs;
255 strs <<
"Receive a new pose" << std::endl;
262 std::cout <<
"pbvs cMo:\n" <<
m_cMo << std::endl;
263 std::cout <<
"pbvs cdMo:\n" <<
m_cdMo << std::endl;
266 std::cout <<
"m_cdMc:\n" <<
m_cdMc << std::endl;
271 std::cout <<
"v: " <<
m_v.t() << std::endl;
276 camvel_msg.twist.linear.x =
m_v[0];
277 camvel_msg.twist.linear.y =
m_v[1];
278 camvel_msg.twist.linear.z =
m_v[2];
279 camvel_msg.twist.angular.x =
m_v[3];
280 camvel_msg.twist.angular.y =
m_v[4];
281 camvel_msg.twist.angular.z =
m_v[5];
287 ROS_INFO(
"Catch an exception: set vel to 0" );
289 camvel_msg.twist.linear.x = 0;
290 camvel_msg.twist.linear.y = 0;
291 camvel_msg.twist.linear.z = 0;
292 camvel_msg.twist.angular.x = 0;
293 camvel_msg.twist.angular.y = 0;
294 camvel_msg.twist.angular.z = 0;
302 if ( msg->data == 0 )
307 geometry_msgs::TwistStamped camvel_msg;
309 camvel_msg.twist.linear.x = 0;
310 camvel_msg.twist.linear.y = 0;
311 camvel_msg.twist.linear.z = 0;
312 camvel_msg.twist.angular.x = 0;
313 camvel_msg.twist.angular.y = 0;
314 camvel_msg.twist.angular.z = 0;
317 else if ( msg->data == 1 )
341 std::cout <<
"PBVS controller stopped..." << std::endl;