3 #include <std_msgs/Int8.h> 4 #include <geometry_msgs/Twist.h> 5 #include <geometry_msgs/PoseStamped.h> 8 #include <sensor_msgs/CameraInfo.h> 10 #include <visp/vpAdaptiveGain.h> 11 #include <visp/vpCameraParameters.h> 12 #include <visp/vpDot.h> 13 #include <visp/vpDot2.h> 14 #include <visp/vpFeatureBuilder.h> 15 #include <visp/vpFeatureDepth.h> 16 #include <visp/vpFeaturePoint.h> 17 #include <visp/vpHomogeneousMatrix.h> 18 #include <visp/vpPioneer.h> 19 #include <visp/vpServo.h> 20 #include <visp/vpVelocityTwistMatrix.h> 38 vpCameraParameters
cam;
57 void poseCallback(
const geometry_msgs::PoseStampedConstPtr& msg);
60 VS(
int argc,
char**argv);
104 task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ;
105 task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ;
109 vpVelocityTwistMatrix cVe = robot.get_cVe();
110 vpMatrix eJe = robot.get_eJe();
114 vpImagePoint ip(0,0);
117 vpFeatureBuilder::create(
s_x,
cam, ip);
123 task.addFeature(
s_x,
s_xd, vpFeaturePoint::selectX()) ;
125 s_Z.buildFrom(
s_x.get_x(),
s_x.get_y(),
Z , 0);
146 std::cout <<
"Waiting for the camera parameters."<<std::endl;
151 geometry_msgs::Twist out_cmd_vel;
155 std::ostringstream strs;
156 strs <<
"Receive a new pose" << std::endl;
164 origin.setWorldCoordinates(0,0,0);
174 out_cmd_vel.linear.x = 0;
175 out_cmd_vel.linear.y = 0;
176 out_cmd_vel.linear.z = 0;
177 out_cmd_vel.angular.x = 0;
178 out_cmd_vel.angular.y = 0;
179 out_cmd_vel.angular.z = 0;
189 s_x.set_xyZ(origin.p[0], origin.p[1],
Z);
195 vpVelocityTwistMatrix cVe = robot.get_cVe();
196 vpMatrix eJe = robot.get_eJe();
201 v =
task.computeControlLaw() ;
212 double max_linear_vel = 0.5;
213 double max_angular_vel = vpMath::rad(50);
215 if (std::abs(
v[0]) > max_linear_vel || std::abs(
v[1]) > max_angular_vel) {
217 for (
unsigned int i=0; i<
v.size(); i++)
222 out_cmd_vel.linear.x =
v[0];
223 out_cmd_vel.linear.y = 0;
224 out_cmd_vel.linear.z = 0;
225 out_cmd_vel.angular.x = 0;
226 out_cmd_vel.angular.y = 0;
227 out_cmd_vel.angular.z =
v[1];
235 ROS_INFO(
"Catch an exception: set vel to 0");
236 out_cmd_vel.linear.x = 0;
237 out_cmd_vel.linear.y = 0;
238 out_cmd_vel.linear.z = 0;
239 out_cmd_vel.angular.x = 0;
240 out_cmd_vel.angular.y = 0;
241 out_cmd_vel.angular.z = 0;
249 std::cout <<
"Received Camera INFO"<<std::endl;
252 cam.printParameters();
265 int main(
int argc,
char **argv)
void publish(const boost::shared_ptr< M > &message) const
VS(int argc, char **argv)
vpHomogeneousMatrix toVispHomogeneousMatrix(const geometry_msgs::Transform &trans)
vpCameraParameters toVispCameraParameters(const sensor_msgs::CameraInfo &cam_info)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void CameraInfoCb(const sensor_msgs::CameraInfo &msg)
void statusCallback(const std_msgs::Int8ConstPtr &msg)
ROSCPP_DECL void spin(Spinner &spinner)
vpAdaptiveGain lambda_adapt
ros::Subscriber sub_cam_info
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void poseCallback(const geometry_msgs::PoseStampedConstPtr &msg)
int main(int argc, char **argv)
ros::Subscriber subStatus_