3 #include <std_msgs/Int8.h> 4 #include <geometry_msgs/Twist.h> 5 #include <geometry_msgs/PoseStamped.h> 9 #include <visp/vpAdaptiveGain.h> 10 #include <visp/vpCameraParameters.h> 11 #include <visp/vpDot.h> 12 #include <visp/vpDot2.h> 13 #include <visp/vpFeatureBuilder.h> 14 #include <visp/vpFeatureDepth.h> 15 #include <visp/vpFeaturePoint.h> 16 #include <visp/vpHomogeneousMatrix.h> 17 #include <visp/vpPioneerPan.h> 18 #include <visp/vpRobot.h> 19 #include <visp/vpServo.h> 20 #include <visp/vpVelocityTwistMatrix.h> 37 vpCameraParameters
cam;
58 void poseCallback(
const geometry_msgs::PoseStampedConstPtr& msg);
61 VS(
int argc,
char**argv);
67 VS::VS(
int argc,
char**argv)
90 v = 0;
vi = 0;
qm = 0;
97 cam.initPersProjWithoutDistortion(800, 795, 320, 216);
99 task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ;
100 task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ;
103 vpVelocityTwistMatrix cVe =
robot.get_cVe();
107 vpMatrix eJe =
robot.get_eJe();
110 vpImagePoint ip(0,0);
113 vpFeatureBuilder::create(
s_x,
cam, ip);
119 task.addFeature(
s_x,
s_xd, vpFeaturePoint::selectX()) ;
121 s_Z.buildFrom(
s_x.get_x(),
s_x.get_y(),
Z , 0);
139 geometry_msgs::PoseStamped position;
140 qm[1] = position.pose.orientation.x;
141 qm[0] = position.pose.orientation.y;
146 geometry_msgs::Twist out_cmd_vel;
147 geometry_msgs::Twist pioneer_cmd_vel;
148 geometry_msgs::Twist biclops_cmd_vel;
152 std::ostringstream strs;
153 strs <<
"Receive a new pose" << std::endl;
161 origin.setWorldCoordinates(0,0,0);
171 out_cmd_vel.linear.x = 0;
172 out_cmd_vel.linear.y = 0;
173 out_cmd_vel.linear.z = 0;
174 out_cmd_vel.angular.x = 0;
175 out_cmd_vel.angular.y = 0;
176 out_cmd_vel.angular.z = 0;
187 s_x.set_xyZ(origin.p[0], origin.p[1],
Z);
192 vpVelocityTwistMatrix cVe =
robot.get_cVe();
198 vpMatrix eJe =
robot.get_eJe();
203 v =
task.computeControlLaw() ;
205 static unsigned long iter = 0;
217 double max_linear_vel = 0.5;
218 double max_angular_vel = vpMath::rad(50);
219 vpColVector v_max(3);
220 v_max[0] = max_linear_vel;
221 v_max[1] = max_angular_vel;
222 v_max[2] = max_angular_vel;
224 vpColVector v_sat = vpRobot::saturateVelocities(
v, v_max);
234 pioneer_cmd_vel.linear.x = v_sat[0];
235 pioneer_cmd_vel.linear.y = 0;
236 pioneer_cmd_vel.linear.z = 0;
237 pioneer_cmd_vel.angular.x = 0;
238 pioneer_cmd_vel.angular.y = 0;
239 pioneer_cmd_vel.angular.z = v_sat[1];
241 biclops_cmd_vel.linear.x = 0;
242 biclops_cmd_vel.linear.y = 0;
243 biclops_cmd_vel.linear.z = 0;
244 biclops_cmd_vel.angular.x = 0;
245 biclops_cmd_vel.angular.y = v_sat[2];
246 biclops_cmd_vel.angular.z = 0;
256 ROS_INFO(
"Catch an exception: set vel to 0");
257 out_cmd_vel.linear.x = 0;
258 out_cmd_vel.linear.y = 0;
259 out_cmd_vel.linear.z = 0;
260 out_cmd_vel.angular.x = 0;
261 out_cmd_vel.angular.y = 0;
262 out_cmd_vel.angular.z = 0;
268 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)
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 statusCallback(const std_msgs::Int8ConstPtr &msg)
ROSCPP_DECL void spin(Spinner &spinner)
vpAdaptiveGain lambda_adapt
ros::Publisher pubTwistPioneer_
void biclopsOdomCallback(const geometry_msgs::PoseStampedConstPtr &msg)
ros::Subscriber subStatusTarget_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
void poseCallback(const geometry_msgs::PoseStampedConstPtr &msg)
ros::Subscriber subBiclopsOdom_
ros::Subscriber subPoseTarget_
ros::Publisher pubTwistBiclops_