|
15 | 15 | namespace rcs { |
16 | 16 | namespace common { |
17 | 17 |
|
18 | | -IK::IK(const std::string& urdf_path, size_t max_duration_ms) : rl() { |
19 | | - this->rl = RL(); |
20 | | - |
21 | | - this->rl.mdl = rl::mdl::UrdfFactory().create(urdf_path); |
22 | | - this->rl.kin = std::dynamic_pointer_cast<rl::mdl::Kinematic>(this->rl.mdl); |
23 | | - this->rl.ik = |
24 | | - std::make_shared<rl::mdl::JacobianInverseKinematics>(this->rl.kin.get()); |
25 | | - this->rl.ik->setRandomRestarts(0); |
26 | | - this->rl.ik->setEpsilon(1e-3); |
27 | | - this->rl.ik->setDuration(std::chrono::milliseconds(max_duration_ms)); |
| 18 | +RL::RL(const std::string& urdf_path, size_t max_duration_ms) : rl_data() { |
| 19 | + this->rl_data.mdl = rl::mdl::UrdfFactory().create(urdf_path); |
| 20 | + this->rl_data.kin = |
| 21 | + std::dynamic_pointer_cast<rl::mdl::Kinematic>(this->rl_data.mdl); |
| 22 | + this->rl_data.ik = std::make_shared<rl::mdl::JacobianInverseKinematics>( |
| 23 | + this->rl_data.kin.get()); |
| 24 | + this->rl_data.ik->setRandomRestarts(0); |
| 25 | + this->rl_data.ik->setEpsilon(1e-3); |
| 26 | + this->rl_data.ik->setDuration(std::chrono::milliseconds(max_duration_ms)); |
28 | 27 | } |
29 | 28 |
|
30 | | -std::optional<Vector7d> IK::ik(const Pose& pose, const Vector7d& q0, |
| 29 | +std::optional<Vector7d> RL::ik(const Pose& pose, const Vector7d& q0, |
31 | 30 | const Pose& tcp_offset) { |
32 | 31 | // pose is assumed to be in the robots coordinate frame |
33 | | - this->rl.kin->setPosition(q0); |
34 | | - this->rl.kin->forwardPosition(); |
| 32 | + this->rl_data.kin->setPosition(q0); |
| 33 | + this->rl_data.kin->forwardPosition(); |
35 | 34 | rcs::common::Pose new_pose = pose * tcp_offset.inverse(); |
36 | 35 |
|
37 | | - this->rl.ik->addGoal(new_pose.affine_matrix(), 0); |
38 | | - bool success = this->rl.ik->solve(); |
| 36 | + this->rl_data.ik->addGoal(new_pose.affine_matrix(), 0); |
| 37 | + bool success = this->rl_data.ik->solve(); |
39 | 38 | if (success) { |
40 | 39 | // is this forward needed and is it mabye possible to call |
41 | 40 | // this on the model? |
42 | | - this->rl.kin->forwardPosition(); |
43 | | - return this->rl.kin->getPosition(); |
| 41 | + this->rl_data.kin->forwardPosition(); |
| 42 | + return this->rl_data.kin->getPosition(); |
44 | 43 | } else { |
45 | 44 | return std::nullopt; |
46 | 45 | } |
|
0 commit comments