3 #include <iCub/ctrl/math.h> 13 InitiCubArm::InitiCubArm(
const ConstString& port_prefix,
const ConstString& cam_sel,
const ConstString& laterality) noexcept :
14 icub_kin_arm_(iCubArm(laterality +
"_v2")), icub_kin_finger_{iCubFinger(laterality +
"_thumb"), iCubFinger(laterality +
"_index"), iCubFinger(laterality +
"_middle")}
16 icub_kin_arm_.setAllConstraints(
false);
17 icub_kin_arm_.releaseLink(0);
18 icub_kin_arm_.releaseLink(1);
19 icub_kin_arm_.releaseLink(2);
21 icub_kin_finger_[0].setAllConstraints(
false);
22 icub_kin_finger_[1].setAllConstraints(
false);
23 icub_kin_finger_[2].setAllConstraints(
false);
25 port_arm_enc_.open (
"/" + port_prefix +
"/cam/" + cam_sel +
"/" + laterality +
"_arm:i");
26 port_torso_enc_.open(
"/" + port_prefix +
"/cam/" + cam_sel +
"/torso:i");
36 port_arm_enc_.close();
37 port_torso_enc_.close();
43 Vector ee_pose = icub_kin_arm_.EndEffPose(CTRL_DEG2RAD * readRootToEE());
45 Map<VectorXd> init_hand_pose(ee_pose.data(), 7, 1);
47 for (
int i = 0; i < state.cols(); ++i)
48 state.col(i) = init_hand_pose.cast<
float>();
50 weight.fill(1.0 / state.cols());
56 Bottle* b = port_torso_enc_.read(
true);
57 if (!b)
return Vector(3, 0.0);
60 torso_enc(0) = b->get(2).asDouble();
61 torso_enc(1) = b->get(1).asDouble();
62 torso_enc(2) = b->get(0).asDouble();
70 Bottle* b = port_arm_enc_.read(
true);
71 if (!b)
return Vector(10, 0.0);
73 Vector root_ee_enc(10);
75 root_ee_enc.setSubvector(0, readTorso());
77 for (
size_t i = 0; i < 7; ++i)
78 root_ee_enc(i + 3) = b->get(i).asDouble();
yarp::sig::Vector readRootToEE()
InitiCubArm(const yarp::os::ConstString &port_prefix, const yarp::os::ConstString &cam_sel, const yarp::os::ConstString &laterality) noexcept
yarp::sig::Vector readTorso()
void initialize(Eigen::Ref< Eigen::MatrixXf > state, Eigen::Ref< Eigen::VectorXf > weight) override