box_to_grasp_candidates.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Dense>
4 
5 #include <SimoxUtility/shapes/OrientedBox.h>
6 #include <SimoxUtility/meta/eigen/enable_if_compile_time_size.h>
7 
9 
10 #include "GraspCandidateHelper.h"
11 
12 namespace armarx
13 {
15  {
17  enum class box_alignment : std::uint_fast8_t
18  {
21 
24 
27 
30 
33 
36  };
38  {
40  {
41  return enabled.at(static_cast<std::uint_fast8_t>(al));
42  }
43  bool& operator[](std::uint_fast8_t al)
44  {
45  return enabled.at(al);
46  }
47  bool operator[](box_alignment al) const
48  {
49  return enabled.at(static_cast<std::uint_fast8_t>(al));
50  }
51  bool operator[](std::uint_fast8_t al) const
52  {
53  return enabled.at(al);
54  }
55  std::array<bool, 24> enabled
56  {
57  0, 0, 0, 0, 0, 0, 0, 0,
58  0, 0, 0, 0, 0, 0, 0, 0,
59  0, 0, 0, 0, 0, 0, 0, 0
60  };
61  };
62 
63  struct length_limit
64  {
66  float transverse_length_max = 1500;
67  float upward_length_min = 25;
68  float upward_length_max = 500;
69  float forward_length_min = 50;
70  float forward_length_max = 150;
71 
72  bool in_limits(const box_t& box, box_alignment align) const;
73  std::string limit_violation_string(const box_t& box, box_alignment align) const;
74  };
75  struct side_data
76  {
77  std::string name;
80  Eigen::Vector3f tcp_shift = Eigen::Vector3f::Constant(std::nanf(""));
81  Eigen::Vector3f hand_up = Eigen::Vector3f::Constant(std::nanf(""));
82  Eigen::Vector3f hand_transverse = Eigen::Vector3f::Constant(std::nanf(""));
83  };
84  struct grasp
85  {
86  Eigen::Matrix4f pose = Eigen::Matrix4f::Constant(std::nanf(""));
87  Eigen::Vector3f approach = Eigen::Vector3f::Constant(std::nanf(""));
88  const side_data* side = nullptr;
89 
90  armarx::grasping::GraspCandidatePtr make_candidate(
91  const std::string& provider_name
92  ) const;
93  armarx::grasping::GraspCandidatePtr make_candidate(
94  const std::string& provider_name,
95  const std::string& side_name,
96  const VirtualRobot::RobotPtr& robot = nullptr
97  ) const;
98  armarx::grasping::GraspCandidatePtr make_candidate(
99  const std::string& provider_name,
100  const std::string& side_name,
101  const Eigen::Matrix4f& global_pose
102  ) const;
103  };
104  public:
106  const VirtualRobot::RobotPtr& robot);
107 
108  void add_armar6_defaults();
109  //extract
110  public:
111  static Eigen::Vector3f box_transverse_axis(const box_t& box, box_alignment align);
112  static float box_transverse_len(const box_t& box, box_alignment align);
113 
114  static Eigen::Vector3f box_up_axis(const box_t& box, box_alignment align);
115  static float box_up_len(const box_t& box, box_alignment align);
116 
117  static float box_forward_len(const box_t& box, box_alignment align);
118  //side
119  public:
120  const side_data& side(const std::string& side) const;
121  side_data& side(const std::string& side);
122  const std::map<std::string, side_data>& sides() const;
123 
124  //center_grasp
125  public:
126  void center_grasps(const box_t& box,
127  const side_data& side,
128  const length_limit& limit,
129  auto consume_grasp);
130  void center_grasps(const box_t& box,
131  const std::string& side,
132  const length_limit& limit,
133  auto consume_grasp);
134  void center_grasps(const box_t& box,
135  const side_data& side,
136  const length_limit& limit,
137  auto consume_grasp,
138  const side_enabled_map& enabled);
139  void center_grasps(const box_t& box,
140  const std::string& side,
141  const length_limit& limit,
142  auto consume_grasp,
143  const side_enabled_map& enabled);
144 
145  grasp center_grasp(const box_t& box,
146  const side_data& side,
148 
149  template<class D1, class D2, class D3>
150  static
151  std::enable_if_t <
152  simox::meta::is_vec3_v<D1>&&
153  simox::meta::is_vec3_v<D2>&&
154  simox::meta::is_vec3_v<D3>, grasp >
155  center_grasp(
156  const Eigen::MatrixBase<D1>& center_pos,
157  const Eigen::MatrixBase<D2>& up, float up_len, const Eigen::Vector3f& hand_up,
158  const Eigen::MatrixBase<D3>& transverse, const Eigen::Vector3f& hand_transv,
159  const Eigen::Vector3f& tcp_shift);
160 
161  private:
163  VirtualRobot::RobotPtr _robot;
164  std::map<std::string, side_data> _sides;
165  };
166 }
167 
armarx::box_to_grasp_candidates::side_enabled_map::operator[]
bool & operator[](box_alignment al)
Definition: box_to_grasp_candidates.h:39
armarx::box_to_grasp_candidates::side_enabled_map::operator[]
bool operator[](box_alignment al) const
Definition: box_to_grasp_candidates.h:47
armarx::box_to_grasp_candidates::center_grasps
void center_grasps(const box_t &box, const side_data &side, const length_limit &limit, auto consume_grasp)
Definition: box_to_grasp_candidates.ipp:96
armarx::box_to_grasp_candidates::box_alignment::neg_x_pos_z
@ neg_x_pos_z
armarx::box_to_grasp_candidates::box_alignment::pos_x_neg_y
@ pos_x_neg_y
armarx::box_to_grasp_candidates::length_limit::upward_length_max
float upward_length_max
Definition: box_to_grasp_candidates.h:68
armarx::box_to_grasp_candidates::length_limit::transverse_length_max
float transverse_length_max
Definition: box_to_grasp_candidates.h:66
armarx::box_to_grasp_candidates::box_alignment::pos_y_pos_x
@ pos_y_pos_x
armarx::box_to_grasp_candidates::box_alignment::neg_z_pos_x
@ neg_z_pos_x
armarx::box_to_grasp_candidates::box_alignment::neg_x_pos_y
@ neg_x_pos_y
armarx::box_to_grasp_candidates::box_alignment::neg_z_pos_y
@ neg_z_pos_y
armarx::box_to_grasp_candidates::box_to_grasp_candidates
box_to_grasp_candidates(armarx::RobotNameHelperPtr rnh, const VirtualRobot::RobotPtr &robot)
Definition: box_to_grasp_candidates.cpp:305
armarx::box_to_grasp_candidates::box_forward_len
static float box_forward_len(const box_t &box, box_alignment align)
Definition: box_to_grasp_candidates.cpp:189
armarx::box_to_grasp_candidates::side_data::tcp_shift
Eigen::Vector3f tcp_shift
Definition: box_to_grasp_candidates.h:80
armarx::box_to_grasp_candidates::box_transverse_len
static float box_transverse_len(const box_t &box, box_alignment align)
Definition: box_to_grasp_candidates.cpp:66
armarx::box_to_grasp_candidates::grasp::make_candidate
armarx::grasping::GraspCandidatePtr make_candidate(const std::string &provider_name) const
Definition: box_to_grasp_candidates.cpp:264
armarx::box_to_grasp_candidates::box_alignment::pos_z_neg_x
@ pos_z_neg_x
armarx::box_to_grasp_candidates::side_data::nh_arm_w_rob
armarx::RobotNameHelper::RobotArm nh_arm_w_rob
Definition: box_to_grasp_candidates.h:79
std::align
void * align(size_t alignment, size_t bytes, void *&bufferPlace, size_t &bufferSpace) noexcept
Definition: HeterogenousContinuousContainer.h:37
GraspCandidateHelper.h
armarx::box_to_grasp_candidates::box_alignment::neg_y_neg_z
@ neg_y_neg_z
armarx::box_to_grasp_candidates::length_limit::upward_length_min
float upward_length_min
Definition: box_to_grasp_candidates.h:67
armarx::box_to_grasp_candidates::side_data
Definition: box_to_grasp_candidates.h:75
armarx::box_to_grasp_candidates::length_limit::transverse_length_min
float transverse_length_min
Definition: box_to_grasp_candidates.h:65
armarx::box_to_grasp_candidates::box_alignment::neg_y_pos_x
@ neg_y_pos_x
armarx::box_to_grasp_candidates::length_limit
Definition: box_to_grasp_candidates.h:63
armarx::box_to_grasp_candidates::side_data::name
std::string name
Definition: box_to_grasp_candidates.h:77
armarx::box_to_grasp_candidates::box_alignment
box_alignment
Definition: box_to_grasp_candidates.h:17
armarx::RobotNameHelperPtr
std::shared_ptr< class RobotNameHelper > RobotNameHelperPtr
Definition: RobotNameHelper.h:34
armarx::box_to_grasp_candidates::length_limit::limit_violation_string
std::string limit_violation_string(const box_t &box, box_alignment align) const
Definition: box_to_grasp_candidates.cpp:242
armarx::box_to_grasp_candidates::box_alignment::neg_y_pos_z
@ neg_y_pos_z
armarx::box_to_grasp_candidates::box_alignment::pos_x_pos_y
@ pos_x_pos_y
armarx::box_to_grasp_candidates::side_data::hand_up
Eigen::Vector3f hand_up
Definition: box_to_grasp_candidates.h:81
armarx::box_to_grasp_candidates::side_data::nh_arm
armarx::RobotNameHelper::Arm nh_arm
Definition: box_to_grasp_candidates.h:78
armarx::box_to_grasp_candidates::box_alignment::neg_x_neg_z
@ neg_x_neg_z
armarx::box_to_grasp_candidates::grasp::pose
Eigen::Matrix4f pose
Definition: box_to_grasp_candidates.h:86
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
armarx::box_to_grasp_candidates::length_limit::forward_length_max
float forward_length_max
Definition: box_to_grasp_candidates.h:70
armarx::box_to_grasp_candidates::side_enabled_map::enabled
std::array< bool, 24 > enabled
Definition: box_to_grasp_candidates.h:56
armarx::box_to_grasp_candidates::add_armar6_defaults
void add_armar6_defaults()
Definition: box_to_grasp_candidates.cpp:11
armarx::box_to_grasp_candidates::box_alignment::pos_x_neg_z
@ pos_x_neg_z
armarx::box_to_grasp_candidates::box_alignment::pos_y_neg_z
@ pos_y_neg_z
armarx::box_to_grasp_candidates::box_alignment::pos_z_pos_y
@ pos_z_pos_y
armarx::box_to_grasp_candidates::box_alignment::pos_z_neg_y
@ pos_z_neg_y
armarx::box_to_grasp_candidates::grasp
Definition: box_to_grasp_candidates.h:84
armarx::box_to_grasp_candidates
Definition: box_to_grasp_candidates.h:14
box_to_grasp_candidates.ipp
armarx::box_to_grasp_candidates::side
const side_data & side(const std::string &side) const
Definition: box_to_grasp_candidates.cpp:311
armarx::RobotArm
Definition: RobotNameHelper.h:103
armarx::box_to_grasp_candidates::center_grasp
grasp center_grasp(const box_t &box, const side_data &side, box_alignment align)
Definition: box_to_grasp_candidates.cpp:336
armarx::box_to_grasp_candidates::box_up_axis
static Eigen::Vector3f box_up_axis(const box_t &box, box_alignment align)
Definition: box_to_grasp_candidates.cpp:107
armarx::box_to_grasp_candidates::box_alignment::pos_z_pos_x
@ pos_z_pos_x
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::box_to_grasp_candidates::side_enabled_map::operator[]
bool operator[](std::uint_fast8_t al) const
Definition: box_to_grasp_candidates.h:51
armarx::box_to_grasp_candidates::box_alignment::neg_y_neg_x
@ neg_y_neg_x
armarx::box_to_grasp_candidates::box_alignment::pos_x_pos_z
@ pos_x_pos_z
armarx::box_to_grasp_candidates::box_alignment::pos_y_pos_z
@ pos_y_pos_z
armarx::box_to_grasp_candidates::box_alignment::neg_z_neg_y
@ neg_z_neg_y
armarx::box_to_grasp_candidates::side_enabled_map::operator[]
bool & operator[](std::uint_fast8_t al)
Definition: box_to_grasp_candidates.h:43
armarx::box_to_grasp_candidates::box_transverse_axis
static Eigen::Vector3f box_transverse_axis(const box_t &box, box_alignment align)
Definition: box_to_grasp_candidates.cpp:25
simox::OrientedBox
Definition: ice_conversions.h:18
armarx::box_to_grasp_candidates::box_alignment::pos_y_neg_x
@ pos_y_neg_x
armarx::Arm
Definition: RobotNameHelper.h:41
armarx::box_to_grasp_candidates::grasp::side
const side_data * side
Definition: box_to_grasp_candidates.h:88
armarx::box_to_grasp_candidates::box_up_len
static float box_up_len(const box_t &box, box_alignment align)
Definition: box_to_grasp_candidates.cpp:148
armarx::box_to_grasp_candidates::sides
const std::map< std::string, side_data > & sides() const
Definition: box_to_grasp_candidates.cpp:331
armarx::box_to_grasp_candidates::length_limit::in_limits
bool in_limits(const box_t &box, box_alignment align) const
Definition: box_to_grasp_candidates.cpp:229
armarx::box_to_grasp_candidates::side_data::hand_transverse
Eigen::Vector3f hand_transverse
Definition: box_to_grasp_candidates.h:82
armarx::box_to_grasp_candidates::grasp::approach
Eigen::Vector3f approach
Definition: box_to_grasp_candidates.h:87
armarx::box_to_grasp_candidates::side_enabled_map
Definition: box_to_grasp_candidates.h:37
armarx::box_to_grasp_candidates::length_limit::forward_length_min
float forward_length_min
Definition: box_to_grasp_candidates.h:69
armarx::box_to_grasp_candidates::box_alignment::neg_x_neg_y
@ neg_x_neg_y
armarx::box_to_grasp_candidates::box_alignment::neg_z_neg_x
@ neg_z_neg_x
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
RobotNameHelper.h
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18