box_to_grasp_candidates.h
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Dense>
4
5#include <SimoxUtility/meta/eigen/enable_if_compile_time_size.h>
6#include <SimoxUtility/shapes/OrientedBox.h>
7
9
11
12namespace armarx
13{
15 {
49
51 {
52 bool&
54 {
55 return enabled.at(static_cast<std::uint_fast8_t>(al));
56 }
57
58 bool&
59 operator[](std::uint_fast8_t al)
60 {
61 return enabled.at(al);
62 }
63
64 bool
66 {
67 return enabled.at(static_cast<std::uint_fast8_t>(al));
68 }
69
70 bool
71 operator[](std::uint_fast8_t al) const
72 {
73 return enabled.at(al);
74 }
75
76 std::array<bool, 24> enabled{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
78 };
79
81 {
85 float upward_length_max = 500;
87 float forward_length_max = 150;
88
89 bool in_limits(const box_t& box, box_alignment align) const;
90 std::string limit_violation_string(const box_t& box, box_alignment align) const;
91 };
92
93 struct side_data
94 {
95 std::string name;
98 Eigen::Vector3f tcp_shift = Eigen::Vector3f::Constant(std::nanf(""));
99 Eigen::Vector3f hand_up = Eigen::Vector3f::Constant(std::nanf(""));
100 Eigen::Vector3f hand_transverse = Eigen::Vector3f::Constant(std::nanf(""));
101 };
102
103 struct grasp
104 {
105 Eigen::Matrix4f pose = Eigen::Matrix4f::Constant(std::nanf(""));
106 Eigen::Vector3f approach = Eigen::Vector3f::Constant(std::nanf(""));
107 const side_data* side = nullptr;
108
109 armarx::grasping::GraspCandidatePtr
110 make_candidate(const std::string& provider_name) const;
111 armarx::grasping::GraspCandidatePtr
112 make_candidate(const std::string& provider_name,
113 const std::string& side_name,
114 const VirtualRobot::RobotPtr& robot = nullptr) const;
115 armarx::grasping::GraspCandidatePtr
116 make_candidate(const std::string& provider_name,
117 const std::string& side_name,
118 const Eigen::Matrix4f& global_pose) const;
119 };
120
121 public:
123 const VirtualRobot::RobotPtr& robot);
124
125 void add_armar6_defaults();
126 //extract
127 public:
128 static Eigen::Vector3f box_transverse_axis(const box_t& box, box_alignment align);
129 static float box_transverse_len(const box_t& box, box_alignment align);
130
131 static Eigen::Vector3f box_up_axis(const box_t& box, box_alignment align);
132 static float box_up_len(const box_t& box, box_alignment align);
133
134 static float box_forward_len(const box_t& box, box_alignment align);
135 //side
136 public:
137 const side_data& side(const std::string& side) const;
138 side_data& side(const std::string& side);
139 const std::map<std::string, side_data>& sides() const;
140
141 //center_grasp
142 public:
143 void center_grasps(const box_t& box,
144 const side_data& side,
145 const length_limit& limit,
146 auto consume_grasp);
147 void center_grasps(const box_t& box,
148 const std::string& side,
149 const length_limit& limit,
150 auto consume_grasp);
151 void center_grasps(const box_t& box,
152 const side_data& side,
153 const length_limit& limit,
154 auto consume_grasp,
155 const side_enabled_map& enabled);
156 void center_grasps(const box_t& box,
157 const std::string& side,
158 const length_limit& limit,
159 auto consume_grasp,
160 const side_enabled_map& enabled);
161
163
164 template <class D1, class D2, class D3>
165 static std::enable_if_t<simox::meta::is_vec3_v<D1> && simox::meta::is_vec3_v<D2> &&
166 simox::meta::is_vec3_v<D3>,
167 grasp>
168 center_grasp(const Eigen::MatrixBase<D1>& center_pos,
169 const Eigen::MatrixBase<D2>& up,
170 float up_len,
171 const Eigen::Vector3f& hand_up,
172 const Eigen::MatrixBase<D3>& transverse,
173 const Eigen::Vector3f& hand_transv,
174 const Eigen::Vector3f& tcp_shift);
175
176 private:
179 std::map<std::string, side_data> _sides;
180 };
181} // namespace armarx
182
armarx::RobotArm RobotArm
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< class RobotNameHelper > RobotNameHelperPtr
void * align(size_t alignment, size_t bytes, void *&bufferPlace, size_t &bufferSpace) noexcept
armarx::grasping::GraspCandidatePtr make_candidate(const std::string &provider_name) const
bool in_limits(const box_t &box, box_alignment align) const
std::string limit_violation_string(const box_t &box, box_alignment align) const
armarx::RobotNameHelper::RobotArm nh_arm_w_rob
static float box_transverse_len(const box_t &box, box_alignment align)
static float box_up_len(const box_t &box, box_alignment align)
static Eigen::Vector3f box_transverse_axis(const box_t &box, box_alignment align)
const side_data & side(const std::string &side) const
static Eigen::Vector3f box_up_axis(const box_t &box, box_alignment align)
static float box_forward_len(const box_t &box, box_alignment align)
grasp center_grasp(const box_t &box, const side_data &side, box_alignment align)
void center_grasps(const box_t &box, const side_data &side, const length_limit &limit, auto consume_grasp)
const std::map< std::string, side_data > & sides() const
simox::OrientedBox< float > box_t
box_to_grasp_candidates(armarx::RobotNameHelperPtr rnh, const VirtualRobot::RobotPtr &robot)