3 #include <std_msgs/Int8.h> 4 #include <geometry_msgs/TwistStamped.h> 5 #include <geometry_msgs/PoseStamped.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/vpDisplayX.h> 18 #include <visp3/gui/vpDisplayGDI.h> 19 #include <visp3/gui/vpDisplayOpenCV.h> 20 #include <visp3/visual_features/vpFeatureTranslation.h> 21 #include <visp3/visual_features/vpFeatureThetaU.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);
117 ROS_ERROR(
"Camera parameters are not set");
128 std::cout <<
"Desired pose: " <<
m_cdMo << std::endl;
135 m_task.setServo(vpServo::EYEINHAND_CAMERA);
136 m_task.setInteractionMatrixType(vpServo::CURRENT);
150 #elif VISP_HAVE_OPENCV 155 std::cout <<
"Camera parameters:\n" <<
m_cam << std::endl;
164 cv::Mat cv_frame = cv_image_ptr->image;
173 std::vector<vpImagePoint> ips;
174 for (
unsigned int i = 0; i < msg->blob_cogs.size(); i++) {
175 vpImagePoint ip(msg->blob_cogs[i].i, msg->blob_cogs[i].j);
177 std::stringstream ss;
179 vpDisplay::displayText(
m_I_grayscale, ip + vpImagePoint(-20, 20), ss.str(), vpColor::red);
196 ROS_ERROR(
"cv_bridge exception: %s", e.what());
203 geometry_msgs::TwistStamped camvel_msg;
209 std::ostringstream strs;
210 strs <<
"Receive a new pose" << std::endl;
217 std::cout <<
"pbvs cMo:\n" << m_cMo << std::endl;
218 std::cout <<
"pbvs cdMo:\n" <<
m_cdMo << std::endl;
221 std::cout <<
"m_cdMc:\n" <<
m_cdMc << std::endl;
226 std::cout <<
"v: " <<
m_v.t() << std::endl;
231 camvel_msg.twist.linear.x =
m_v[0];
232 camvel_msg.twist.linear.y =
m_v[1];
233 camvel_msg.twist.linear.z =
m_v[2];
234 camvel_msg.twist.angular.x =
m_v[3];
235 camvel_msg.twist.angular.y =
m_v[4];
236 camvel_msg.twist.angular.z =
m_v[5];
241 ROS_INFO(
"Catch an exception: set vel to 0");
243 camvel_msg.twist.linear.x = 0;
244 camvel_msg.twist.linear.y = 0;
245 camvel_msg.twist.linear.z = 0;
246 camvel_msg.twist.angular.x = 0;
247 camvel_msg.twist.angular.y = 0;
248 camvel_msg.twist.angular.z = 0;
255 if (msg->data == 0) {
259 geometry_msgs::TwistStamped camvel_msg;
261 camvel_msg.twist.linear.x = 0;
262 camvel_msg.twist.linear.y = 0;
263 camvel_msg.twist.linear.z = 0;
264 camvel_msg.twist.angular.x = 0;
265 camvel_msg.twist.angular.y = 0;
266 camvel_msg.twist.angular.z = 0;
269 else if (msg->data == 1) {
288 std::cout <<
"PBVS controller stopped..." << std::endl;
291 int main(
int argc,
char **argv)
void status_callback(const std_msgs::Int8ConstPtr &msg)
std::vector< std::vector< vpImagePoint > > ips_trajectory
ros::Subscriber m_subData
void data_callback(const visp_ros::BlobTracker::ConstPtr &msg)
void publish(const boost::shared_ptr< M > &message) const
VS(int argc, char **argv)
vpFeatureTranslation m_s_t
vpHomogeneousMatrix toVispHomogeneousMatrix(const geometry_msgs::Transform &trans)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
vpAdaptiveGain m_lambda_adapt
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void display(const visp_ros::BlobTracker::ConstPtr &msg)
vpHomogeneousMatrix m_cdMc
CvImagePtr toCvCopy(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
ros::Publisher m_pubTwist
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
vpHomogeneousMatrix m_cMo
vpImage< unsigned char > m_I_grayscale
bool getParam(const std::string &key, std::string &s) const
vpFeatureTranslation m_s_t_d
ros::Subscriber m_subStatus
int main(int argc, char **argv)
ROSCPP_DECL void spinOnce()
vpHomogeneousMatrix m_cdMo