visual-tracking-control
PlayGatePose.cpp
Go to the documentation of this file.
1 #include <PlayGatePose.h>
2 
3 #include <iCub/ctrl/math.h>
4 #include <yarp/eigen/Eigen.h>
5 #include <yarp/os/LogStream.h>
6 #include <yarp/os/Property.h>
7 
8 using namespace bfl;
9 using namespace cv;
10 using namespace Eigen;
11 using namespace iCub::ctrl;
12 using namespace iCub::iKin;
13 using namespace yarp::eigen;
14 using namespace yarp::math;
15 using namespace yarp::os;
16 using namespace yarp::sig;
17 
18 
19 PlayGatePose::PlayGatePose(std::unique_ptr<PFVisualCorrection> visual_correction,
20  const double gate_x, const double gate_y, const double gate_z,
21  const double gate_rotation,
22  const double gate_aperture,
23  const yarp::os::ConstString& robot, const yarp::os::ConstString& laterality, const yarp::os::ConstString& port_prefix) noexcept :
24  GatePose(std::move(visual_correction),
25  gate_x, gate_y, gate_z,
26  gate_rotation,
27  gate_aperture),
28  icub_kin_arm_(iCubArm(laterality + "_v2")), robot_(robot), laterality_(laterality), port_prefix_(port_prefix)
29 {
30  icub_kin_arm_.setAllConstraints(false);
31  icub_kin_arm_.releaseLink(0);
32  icub_kin_arm_.releaseLink(1);
33  icub_kin_arm_.releaseLink(2);
34 
35 
36  port_arm_enc_.open ("/hand-tracking/" + ID_ + "/" + port_prefix_ + "/" + laterality_ + "_arm:i");
37  port_torso_enc_.open("/hand-tracking/" + ID_ + "/" + port_prefix_ + "/torso:i");
38 
39 
40  yInfo() << log_ID_ << "Succesfully initialized.";
41 }
42 
43 
44 PlayGatePose::PlayGatePose(std::unique_ptr<PFVisualCorrection> visual_correction,
45  const yarp::os::ConstString& robot, const yarp::os::ConstString& laterality, const yarp::os::ConstString& port_prefix) noexcept :
46  PlayGatePose(std::move(visual_correction), 0.1, 0.1, 0.1, 5, 30, robot, laterality, port_prefix) { }
47 
48 
50 
51 
53 {
54  Bottle* b = port_torso_enc_.read(true);
55  if (!b) return Vector(3, 0.0);
56 
57  Vector torso_enc(3);
58  torso_enc(0) = b->get(2).asDouble();
59  torso_enc(1) = b->get(1).asDouble();
60  torso_enc(2) = b->get(0).asDouble();
61 
62  return torso_enc;
63 }
64 
65 
67 {
68  Bottle* b = port_arm_enc_.read(true);
69  if (!b) return Vector(10, 0.0);
70 
71  Vector root_ee_enc(10);
72  root_ee_enc.setSubvector(0, readTorso());
73  for (size_t i = 0; i < 7; ++i)
74  {
75  root_ee_enc(i+3) = b->get(i).asDouble();
76  }
77 
78  return root_ee_enc;
79 }
80 
81 
83 {
84  Vector ee_pose = icub_kin_arm_.EndEffPose(CTRL_DEG2RAD * readRootToEE());
85 
86  return toEigen(ee_pose);
87 }
PlayGatePose(std::unique_ptr< PFVisualCorrection > visual_correction, const double gate_x, const double gate_y, const double gate_z, const double gate_aperture, const double gate_rotation, const yarp::os::ConstString &robot, const yarp::os::ConstString &laterality, const yarp::os::ConstString &port_prefix) noexcept
Eigen::VectorXd readPose() override
yarp::sig::Vector readTorso()
~PlayGatePose() noexcept override
yarp::sig::Vector readRootToEE()