Robotis Manipulator  1.0.0
robotis_manipulator_common.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2018 ROBOTIS CO., LTD.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 
17 /* Authors: Darby Lim, Hye-Jong KIM, Ryan Shim, Yong-Ho Na */
18 
26 #include "../../include/robotis_manipulator/robotis_manipulator_common.h"
27 
28 using namespace robotis_manipulator;
29 
31 
32 /*****************************************************************************
33 ** Add Function
34 *****************************************************************************/
35 void Manipulator::addWorld(Name world_name,
36  Name child_name,
37  Eigen::Vector3d world_position,
38  Eigen::Matrix3d world_orientation)
39 {
40  world_.name = world_name;
41  world_.child = child_name;
42  world_.pose.kinematic.position = world_position;
43  world_.pose.kinematic.orientation = world_orientation;
44  world_.pose.dynamic.linear.velocity = Eigen::Vector3d::Zero();
45  world_.pose.dynamic.linear.acceleration = Eigen::Vector3d::Zero();
46  world_.pose.dynamic.angular.velocity = Eigen::Vector3d::Zero();
47  world_.pose.dynamic.angular.acceleration = Eigen::Vector3d::Zero();
48 }
49 
51  Name parent_name,
52  Name child_name,
53  Eigen::Vector3d relative_position,
54  Eigen::Matrix3d relative_orientation,
55  Eigen::Vector3d axis_of_rotation,
56  int8_t joint_actuator_id,
57  double max_position_limit,
58  double min_position_limit,
59  double coefficient,
60  double mass,
61  Eigen::Matrix3d inertia_tensor,
62  Eigen::Vector3d center_of_mass)
63 {
64  Component temp_component;
65  if (joint_actuator_id != -1)
66  {
67  dof_++;
68  temp_component.component_type = ACTIVE_JOINT_COMPONENT;
69  }
70  else
71  {
72  temp_component.component_type = PASSIVE_JOINT_COMPONENT;
73  }
74 
75  temp_component.name.parent = parent_name;
76  temp_component.name.child.push_back(child_name);
77  temp_component.relative.pose_from_parent.position = relative_position;
78  temp_component.relative.pose_from_parent.orientation = relative_orientation;
79  temp_component.relative.inertia.mass = mass;
80  temp_component.relative.inertia.inertia_tensor = inertia_tensor;
81  temp_component.relative.inertia.center_of_mass = center_of_mass;
82  temp_component.joint_constant.id = joint_actuator_id;
83  temp_component.joint_constant.coefficient = coefficient;
84  temp_component.joint_constant.axis = axis_of_rotation;
85  temp_component.joint_constant.position_limit.maximum = max_position_limit;
86  temp_component.joint_constant.position_limit.minimum = min_position_limit;
87 
88  temp_component.pose_from_world.kinematic.position = Eigen::Vector3d::Zero();
89  temp_component.pose_from_world.kinematic.orientation = Eigen::Matrix3d::Identity();
90  temp_component.pose_from_world.dynamic.linear.velocity = Eigen::Vector3d::Zero();
91  temp_component.pose_from_world.dynamic.linear.acceleration = Eigen::Vector3d::Zero();
92  temp_component.pose_from_world.dynamic.angular.velocity = Eigen::Vector3d::Zero();
93  temp_component.pose_from_world.dynamic.angular.acceleration = Eigen::Vector3d::Zero();
94 
95  temp_component.joint_value.position = 0.0;
96  temp_component.joint_value.velocity = 0.0;
97  temp_component.joint_value.effort = 0.0;
98 
99  component_.insert(std::make_pair(my_name, temp_component));
100 }
101 
103  Name parent_name,
104  Eigen::Vector3d relative_position,
105  Eigen::Matrix3d relative_orientation,
106  int8_t tool_id,
107  double max_position_limit,
108  double min_position_limit,
109  double coefficient,
110  double mass,
111  Eigen::Matrix3d inertia_tensor,
112  Eigen::Vector3d center_of_mass)
113 {
114  Component temp_component;
115 
116  temp_component.name.parent = parent_name;
117  temp_component.name.child.resize(0);
118  temp_component.component_type = TOOL_COMPONENT;
119  temp_component.relative.pose_from_parent.position = relative_position;
120  temp_component.relative.pose_from_parent.orientation = relative_orientation;
121  temp_component.relative.inertia.mass = mass;
122  temp_component.relative.inertia.inertia_tensor = inertia_tensor;
123  temp_component.relative.inertia.center_of_mass = center_of_mass;
124  temp_component.joint_constant.id = tool_id;
125  temp_component.joint_constant.coefficient = coefficient;
126  temp_component.joint_constant.axis = Eigen::Vector3d::Zero();
127  temp_component.joint_constant.position_limit.maximum = max_position_limit;
128  temp_component.joint_constant.position_limit.minimum = min_position_limit;
129 
130  temp_component.pose_from_world.kinematic.position = Eigen::Vector3d::Zero();
131  temp_component.pose_from_world.kinematic.orientation = Eigen::Matrix3d::Identity();
132  temp_component.pose_from_world.dynamic.linear.velocity = Eigen::Vector3d::Zero();
133  temp_component.pose_from_world.dynamic.linear.acceleration = Eigen::Vector3d::Zero();
134  temp_component.pose_from_world.dynamic.angular.velocity = Eigen::Vector3d::Zero();
135  temp_component.pose_from_world.dynamic.angular.acceleration = Eigen::Vector3d::Zero();
136 
137  temp_component.joint_value.position = 0.0;
138  temp_component.joint_value.velocity = 0.0;
139  temp_component.joint_value.effort = 0.0;
140 
141  component_.insert(std::make_pair(my_name, temp_component));
142 }
143 
144 void Manipulator::addComponentChild(Name my_name, Name child_name)
145 {
146  component_.at(my_name).name.child.push_back(child_name);
147 }
148 
150 {
151  log::println("----------<Manipulator Description>----------");
152  log::println("<Degree of Freedom>\n", dof_);
153  log::println("<Number of Components>\n", component_.size());
154  log::println("");
155  log::println("<World Configuration>");
156  log::println(" [Name]");
157  log::print(" -World Name : "); log::println(STRING(world_.name));
158  log::print(" -Child Name : "); log::println(STRING(world_.child));
159  log::println(" [Static Pose]");
160  log::println(" -Position : ");
162  log::println(" -Orientation : ");
164  log::println(" [Dynamic Pose]");
165  log::println(" -Linear Velocity : ");
167  log::println(" -Linear acceleration : ");
169  log::println(" -Angular Velocity : ");
171  log::println(" -Angular acceleration : ");
173 
174  std::vector<double> result_vector;
175  std::map<Name, Component>::iterator it_component;
176 
177  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
178  {
179  log::println("");
180  log::println("<"); log::print(STRING(it_component->first)); log::print("Configuration>");
181  if(component_.at(it_component->first).component_type == ACTIVE_JOINT_COMPONENT)
182  log::println(" [Component Type]\n Active Joint");
183  else if(component_.at(it_component->first).component_type == PASSIVE_JOINT_COMPONENT)
184  log::println(" [Component Type]\n Passive Joint");
185  else if(component_.at(it_component->first).component_type == TOOL_COMPONENT)
186  log::println(" [Component Type]\n Tool");
187  log::println(" [Name]");
188  log::print(" -Parent Name : "); log::println(STRING(component_.at(it_component->first).name.parent));
189  for(uint32_t index = 0; index < component_.at(it_component->first).name.child.size(); index++)
190  {
191  log::print(" -Child Name",index+1,0);
192  log::print(" : ");
193  log::println(STRING(component_.at(it_component->first).name.child.at(index)));
194  }
195  log::println(" [Actuator]");
196  log::print(" -Actuator Name : ");
197  log::println(STRING(component_.at(it_component->first).actuator_name));
198  log::print(" -ID : ");
199  log::println("", component_.at(it_component->first).joint_constant.id,0);
200  log::println(" -Joint Axis : ");
201  log::print_vector(component_.at(it_component->first).joint_constant.axis);
202  log::print(" -Coefficient : ");
203  log::println("", component_.at(it_component->first).joint_constant.coefficient);
204  log::println(" -Position Limit : ");
205  log::print(" Maximum :", component_.at(it_component->first).joint_constant.position_limit.maximum);
206  log::println(", Minimum :", component_.at(it_component->first).joint_constant.position_limit.minimum);
207 
208  log::println(" [Actuator Value]");
209  log::println(" -Position : ", component_.at(it_component->first).joint_value.position);
210  log::println(" -Velocity : ", component_.at(it_component->first).joint_value.velocity);
211  log::println(" -Acceleration : ", component_.at(it_component->first).joint_value.acceleration);
212  log::println(" -Effort : ", component_.at(it_component->first).joint_value.effort);
213 
214  log::println(" [Constant]");
215  log::println(" -Relative Position from parent component : ");
216  log::print_vector(component_.at(it_component->first).relative.pose_from_parent.position);
217  log::println(" -Relative Orientation from parent component : ");
218  log::print_matrix(component_.at(it_component->first).relative.pose_from_parent.orientation);
219  log::print(" -Mass : ");
220  log::println("", component_.at(it_component->first).relative.inertia.mass);
221  log::println(" -Inertia Tensor : ");
222  log::print_matrix(component_.at(it_component->first).relative.inertia.inertia_tensor);
223  log::println(" -Center of Mass : ");
224  log::print_vector(component_.at(it_component->first).relative.inertia.center_of_mass);
225 
226  log::println(" [Variable]");
227  log::println(" -Position : ");
228  log::print_vector(component_.at(it_component->first).pose_from_world.kinematic.position);
229  log::println(" -Orientation : ");
230  log::print_matrix(component_.at(it_component->first).pose_from_world.kinematic.orientation);
231  log::println(" -Linear Velocity : ");
232  log::print_vector(component_.at(it_component->first).pose_from_world.dynamic.linear.velocity);
233  log::println(" -Linear acceleration : ");
234  log::print_vector(component_.at(it_component->first).pose_from_world.dynamic.linear.acceleration);
235  log::println(" -Angular Velocity : ");
236  log::print_vector(component_.at(it_component->first).pose_from_world.dynamic.angular.velocity);
237  log::println(" -Angular acceleration : ");
238  log::print_vector(component_.at(it_component->first).pose_from_world.dynamic.angular.acceleration);
239  }
240  log::println("---------------------------------------------");
241 }
242 
243 
244 /*****************************************************************************
245 ** Set Function
246 *****************************************************************************/
248 {
249  world_.pose = world_pose;
250 }
251 
253 {
254  world_.pose.kinematic = world_kinematic_pose;
255 }
256 
257 void Manipulator::setWorldPosition(Eigen::Vector3d world_position)
258 {
259  world_.pose.kinematic.position = world_position;
260 }
261 
262 void Manipulator::setWorldOrientation(Eigen::Matrix3d world_orientation)
263 {
264  world_.pose.kinematic.orientation = world_orientation;
265 }
266 
268 {
269  world_.pose.dynamic = world_dynamic_pose;
270 }
271 
272 void Manipulator::setWorldLinearVelocity(Eigen::Vector3d world_linear_velocity)
273 {
274  world_.pose.dynamic.linear.velocity = world_linear_velocity;
275 }
276 
277 void Manipulator::setWorldAngularVelocity(Eigen::Vector3d world_angular_velocity)
278 {
279  world_.pose.dynamic.angular.velocity = world_angular_velocity;
280 }
281 
282 void Manipulator::setWorldLinearAcceleration(Eigen::Vector3d world_linear_acceleration)
283 {
284  world_.pose.dynamic.linear.acceleration = world_linear_acceleration;
285 }
286 
287 void Manipulator::setWorldAngularAcceleration(Eigen::Vector3d world_angular_acceleration)
288 {
289  world_.pose.dynamic.angular.acceleration = world_angular_acceleration;
290 }
291 
292 void Manipulator::setComponent(Name component_name, Component component)
293 {
294  component_.at(component_name) = component;
295 }
296 
297 void Manipulator::setComponentActuatorName(Name component_name, Name actuator_name)
298 {
299  component_.at(component_name).actuator_name = actuator_name;
300 }
301 
302 void Manipulator::setComponentPoseFromWorld(Name component_name, Pose pose_to_world)
303 {
304  if (component_.find(component_name) != component_.end())
305  {
306  component_.at(component_name).pose_from_world = pose_to_world;
307  }
308  else
309  {
310  log::error("[setComponentPoseFromWorld] Wrong name.");
311  }
312 }
313 
315 {
316  if (component_.find(component_name) != component_.end())
317  {
318  component_.at(component_name).pose_from_world.kinematic = pose_to_world;
319  }
320  else
321  {
322  log::error("[setComponentKinematicPoseFromWorld] Wrong name.");
323  }
324 }
325 
326 void Manipulator::setComponentPositionFromWorld(Name component_name, Eigen::Vector3d position_to_world)
327 {
328  if (component_.find(component_name) != component_.end())
329  {
330  component_.at(component_name).pose_from_world.kinematic.position = position_to_world;
331  }
332  else
333  {
334  log::error("[setComponentPositionFromWorld] Wrong name.");
335  }
336 }
337 
338 void Manipulator::setComponentOrientationFromWorld(Name component_name, Eigen::Matrix3d orientation_to_wolrd)
339 {
340  if (component_.find(component_name) != component_.end())
341  {
342  component_.at(component_name).pose_from_world.kinematic.orientation = orientation_to_wolrd;
343  }
344  else
345  {
346  log::error("[setComponentOrientationFromWorld] Wrong name.");
347  }
348 }
349 
351 {
352  if (component_.find(component_name) != component_.end())
353  {
354  component_.at(component_name).pose_from_world.dynamic = dynamic_pose;
355  }
356  else
357  {
358  log::error("[setComponentDynamicPoseFromWorld] Wrong name.");
359  }
360 }
361 
362 void Manipulator::setJointPosition(Name component_name, double position)
363 {
364  component_.at(component_name).joint_value.position = position;
365 }
366 
367 void Manipulator::setJointVelocity(Name component_name, double velocity)
368 {
369  component_.at(component_name).joint_value.velocity = velocity;
370 }
371 
372 void Manipulator::setJointAcceleration(Name component_name, double acceleration)
373 {
374  component_.at(component_name).joint_value.acceleration = acceleration;
375 }
376 
377 void Manipulator::setJointEffort(Name component_name, double effort)
378 {
379  component_.at(component_name).joint_value.effort = effort;
380 }
381 
382 void Manipulator::setJointValue(Name component_name, JointValue joint_value)
383 {
384  component_.at(component_name).joint_value = joint_value;
385 }
386 
387 void Manipulator::setAllActiveJointPosition(std::vector<double> joint_position_vector)
388 {
389  int8_t index = 0;
390  std::map<Name, Component>::iterator it_component;
391 
392  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
393  {
394  if (component_.at(it_component->first).component_type == ACTIVE_JOINT_COMPONENT)
395  {
396  component_.at(it_component->first).joint_value.position = joint_position_vector.at(index);
397  index++;
398  }
399  }
400 }
401 
402 void Manipulator::setAllActiveJointValue(std::vector<JointValue> joint_value_vector)
403 {
404  int8_t index = 0;
405  std::map<Name, Component>::iterator it_component;
406 
407  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
408  {
409  if (component_.at(it_component->first).component_type == ACTIVE_JOINT_COMPONENT)
410  {
411  component_.at(it_component->first).joint_value.position = joint_value_vector.at(index).position;
412  component_.at(it_component->first).joint_value.velocity = joint_value_vector.at(index).velocity;
413  component_.at(it_component->first).joint_value.acceleration = joint_value_vector.at(index).acceleration;
414  component_.at(it_component->first).joint_value.effort = joint_value_vector.at(index).effort;
415  index++;
416  }
417  }
418 }
419 
420 void Manipulator::setAllJointPosition(std::vector<double> joint_position_vector)
421 {
422  int8_t index = 0;
423  std::map<Name, Component>::iterator it_component;
424 
425  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
426  {
427  if (component_.at(it_component->first).component_type == ACTIVE_JOINT_COMPONENT || component_.at(it_component->first).component_type == PASSIVE_JOINT_COMPONENT)
428  {
429  component_.at(it_component->first).joint_value.position = joint_position_vector.at(index);
430  index++;
431  }
432  }
433 }
434 
435 void Manipulator::setAllJointValue(std::vector<JointValue> joint_value_vector)
436 {
437  int8_t index = 0;
438  std::map<Name, Component>::iterator it_component;
439 
440  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
441  {
442  if (component_.at(it_component->first).component_type == ACTIVE_JOINT_COMPONENT || component_.at(it_component->first).component_type == PASSIVE_JOINT_COMPONENT)
443  {
444  component_.at(it_component->first).joint_value = joint_value_vector.at(index);
445  index++;
446  }
447  }
448 }
449 
450 void Manipulator::setAllToolPosition(std::vector<double> tool_position_vector)
451 {
452  int8_t index = 0;
453  std::map<Name, Component>::iterator it_component;
454 
455  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
456  {
457  if (component_.at(it_component->first).component_type == TOOL_COMPONENT)
458  {
459  component_.at(it_component->first).joint_value.position = tool_position_vector.at(index);
460  index++;
461  }
462  }
463 }
464 
465 void Manipulator::setAllToolValue(std::vector<JointValue> tool_value_vector)
466 {
467  int8_t index = 0;
468  std::map<Name, Component>::iterator it_component;
469 
470  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
471  {
472  if (component_.at(it_component->first).component_type == TOOL_COMPONENT)
473  {
474  component_.at(it_component->first).joint_value = tool_value_vector.at(index);
475  index++;
476  }
477  }
478 }
479 
480 
481 /*****************************************************************************
482 ** Get Function
483 *****************************************************************************/
485 {
486  return dof_;
487 }
488 
490 {
491  return world_.name;
492 }
493 
495 {
496  return world_.child;
497 }
498 
500 {
501  return world_.pose;
502 }
503 
505 {
506  return world_.pose.kinematic;
507 }
508 
510 {
511  return world_.pose.kinematic.position;
512 }
513 
515 {
517 }
518 
520 {
521  return world_.pose.dynamic;
522 }
523 
525 {
526  return component_.size();
527 }
528 
529 std::map<Name, Component> Manipulator::getAllComponent()
530 {
531  return component_;
532 }
533 
534 std::map<Name, Component>::iterator Manipulator::getIteratorBegin()
535 {
536  return component_.begin();
537 }
538 
539 std::map<Name, Component>::iterator Manipulator::getIteratorEnd()
540 {
541  return component_.end();;
542 }
543 
545 {
546  return component_.at(component_name);
547 }
548 
550 {
551  return component_.at(component_name).actuator_name;
552 }
553 
555 {
556  return component_.at(component_name).name.parent;
557 }
558 
559 std::vector<Name> Manipulator::getComponentChildName(Name component_name)
560 {
561  return component_.at(component_name).name.child;
562 }
563 
565 {
566  return component_.at(component_name).pose_from_world;
567 }
568 
570 {
571  return component_.at(component_name).pose_from_world.kinematic;
572 }
573 
574 Eigen::Vector3d Manipulator::getComponentPositionFromWorld(Name component_name)
575 {
576  return component_.at(component_name).pose_from_world.kinematic.position;
577 }
578 
580 {
581  return component_.at(component_name).pose_from_world.kinematic.orientation;
582 }
583 
585 {
586  return component_.at(component_name).pose_from_world.dynamic;
587 }
588 
590 {
591  return component_.at(component_name).relative.pose_from_parent;
592 }
593 
595 {
596  return component_.at(component_name).relative.pose_from_parent.position;
597 }
598 
600 {
601  return component_.at(component_name).relative.pose_from_parent.orientation;
602 }
603 
604 int8_t Manipulator::getId(Name component_name)
605 {
606  return component_.at(component_name).joint_constant.id;
607 }
608 
609 double Manipulator::getCoefficient(Name component_name)
610 {
611  return component_.at(component_name).joint_constant.coefficient;
612 }
613 
614 Eigen::Vector3d Manipulator::getAxis(Name component_name)
615 {
616  return component_.at(component_name).joint_constant.axis;
617 }
618 
619 double Manipulator::getJointPosition(Name component_name)
620 {
621  return component_.at(component_name).joint_value.position;
622 }
623 
624 double Manipulator::getJointVelocity(Name component_name)
625 {
626  return component_.at(component_name).joint_value.velocity;
627 }
628 
630 {
631  return component_.at(component_name).joint_value.acceleration;
632 }
633 
634 double Manipulator::getJointEffort(Name component_name)
635 {
636  return component_.at(component_name).joint_value.effort;
637 }
638 
640 {
641  return component_.at(component_name).joint_value;
642 }
643 
644 double Manipulator::getComponentMass(Name component_name)
645 {
646  return component_.at(component_name).relative.inertia.mass;
647 }
648 
649 Eigen::Matrix3d Manipulator::getComponentInertiaTensor(Name component_name)
650 {
651  return component_.at(component_name).relative.inertia.inertia_tensor;
652 }
653 
654 Eigen::Vector3d Manipulator::getComponentCenterOfMass(Name component_name)
655 {
656  return component_.at(component_name).relative.inertia.center_of_mass;
657 }
658 
659 std::vector<double> Manipulator::getAllJointPosition()
660 {
661  std::vector<double> result_vector;
662  std::map<Name, Component>::iterator it_component;
663 
664  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
665  {
666  if (checkComponentType(it_component->first, ACTIVE_JOINT_COMPONENT) || checkComponentType(it_component->first, PASSIVE_JOINT_COMPONENT))
667  {
668  result_vector.push_back(component_.at(it_component->first).joint_value.position);
669  }
670  }
671  return result_vector;
672 }
673 
674 std::vector<JointValue> Manipulator::getAllJointValue()
675 {
676  std::vector<JointValue> result_vector;
677  std::map<Name, Component>::iterator it_component;
678 
679  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
680  {
681  if (checkComponentType(it_component->first, ACTIVE_JOINT_COMPONENT) || checkComponentType(it_component->first, PASSIVE_JOINT_COMPONENT))
682  {
683  result_vector.push_back(component_.at(it_component->first).joint_value);
684  }
685  }
686  return result_vector;
687 }
688 
690 {
691  std::vector<double> result_vector;
692  std::map<Name, Component>::iterator it_component;
693 
694  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
695  {
696  if (checkComponentType(it_component->first, ACTIVE_JOINT_COMPONENT))
697  {
698  result_vector.push_back(component_.at(it_component->first).joint_value.position);
699  }
700  }
701  return result_vector;
702 }
703 
704 std::vector<JointValue> Manipulator::getAllActiveJointValue()
705 {
706  std::vector<JointValue> result_vector;
707  std::map<Name, Component>::iterator it_component;
708 
709  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
710  {
711  if (checkComponentType(it_component->first, ACTIVE_JOINT_COMPONENT))
712  {
713  result_vector.push_back(component_.at(it_component->first).joint_value);
714  }
715  }
716  return result_vector;
717 }
718 
719 std::vector<double> Manipulator::getAllToolPosition()
720 {
721  std::vector<double> result_vector;
722  std::map<Name, Component>::iterator it_component;
723 
724  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
725  {
726  if (checkComponentType(it_component->first, TOOL_COMPONENT))
727  {
728  result_vector.push_back(component_.at(it_component->first).joint_value.position);
729  }
730  }
731  return result_vector;
732 }
733 
734 
735 std::vector<JointValue> Manipulator::getAllToolValue()
736 {
737  std::vector<JointValue> result_vector;
738  std::map<Name, Component>::iterator it_component;
739 
740  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
741  {
742  if (checkComponentType(it_component->first, TOOL_COMPONENT))
743  {
744  result_vector.push_back(component_.at(it_component->first).joint_value);
745  }
746  }
747  return result_vector;
748 }
749 
750 std::vector<uint8_t> Manipulator::getAllJointID()
751 {
752  std::vector<uint8_t> joint_id;
753  std::map<Name, Component>::iterator it_component;
754 
755  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
756  {
757  if (checkComponentType(it_component->first, ACTIVE_JOINT_COMPONENT) || checkComponentType(it_component->first, PASSIVE_JOINT_COMPONENT))
758  {
759  joint_id.push_back(component_.at(it_component->first).joint_constant.id);
760  }
761  }
762  return joint_id;
763 }
764 
765 std::vector<uint8_t> Manipulator::getAllActiveJointID()
766 {
767  std::vector<uint8_t> active_joint_id;
768  std::map<Name, Component>::iterator it_component;
769 
770  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
771  {
772  if (checkComponentType(it_component->first, ACTIVE_JOINT_COMPONENT))
773  {
774  active_joint_id.push_back(component_.at(it_component->first).joint_constant.id);
775  }
776  }
777  return active_joint_id;
778 }
779 
780 
782 {
783  std::vector<Name> tool_name;
784  std::map<Name, Component>::iterator it_component;
785 
786  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
787  {
788  if (checkComponentType(it_component->first, TOOL_COMPONENT))
789  {
790  tool_name.push_back(it_component->first);
791  }
792  }
793  return tool_name;
794 }
795 
797 {
798  std::vector<Name> active_joint_name;
799  std::map<Name, Component>::iterator it_component;
800 
801  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
802  {
803  if (checkComponentType(it_component->first, ACTIVE_JOINT_COMPONENT))
804  {
805  active_joint_name.push_back(it_component->first);
806  }
807  }
808  return active_joint_name;
809 }
810 
811 
812 /*****************************************************************************
813 ** Check Function
814 *****************************************************************************/
815 bool Manipulator::checkJointLimit(Name component_name, double value)
816 {
817  if(component_.at(component_name).joint_constant.position_limit.maximum < value)
818  return false;
819  else if(component_.at(component_name).joint_constant.position_limit.minimum > value)
820  return false;
821  else
822  return true;
823 }
824 
825 bool Manipulator::checkComponentType(Name component_name, ComponentType component_type)
826 {
827  if(component_.at(component_name).component_type == component_type)
828  return true;
829  else
830  return false;
831 }
832 
833 
834 /*****************************************************************************
835 ** Find Function
836 *****************************************************************************/
838 {
839  std::map<Name, Component>::iterator it_component;
840 
841  for (it_component = component_.begin(); it_component != component_.end(); it_component++)
842  {
843  if (component_.at(it_component->first).joint_constant.id == id)
844  {
845  return it_component->first;
846  }
847  }
848  return {};
849 }
std::vector< uint8_t > getAllJointID()
getAllJointID
void setAllToolValue(std::vector< JointValue > tool_value_vector)
setAllToolValue
void printManipulatorSetting()
printManipulatorSetting
void setComponentKinematicPoseFromWorld(Name component_name, KinematicPose pose_to_world)
setComponentKinematicPoseFromWorld
void setAllToolPosition(std::vector< double > tool_position_vector)
setAllToolPosition
Eigen::Matrix3d getComponentInertiaTensor(Name component_name)
getComponentInertiaTensor
int8_t getId(Name component_name)
getId
KinematicPose getComponentRelativePoseFromParent(Name component_name)
getComponentRelativePoseFromParent
void setComponentDynamicPoseFromWorld(Name component_name, DynamicPose dynamic_pose)
setComponentDynamicPoseFromWorld
void setWorldKinematicPose(KinematicPose world_kinematic_pose)
setWorldKinematicPose
std::vector< JointValue > getAllActiveJointValue()
getAllActiveJointValue
void setAllJointValue(std::vector< JointValue > joint_value_vector)
setAllJointValue
Eigen::Matrix3d getWorldOrientation()
getWorldOrientation
void setComponentPoseFromWorld(Name component_name, Pose pose_to_world)
setComponentPoseFromWorld
main namespace
double getCoefficient(Name component_name)
getCoefficient
void setAllActiveJointValue(std::vector< JointValue > joint_value_vector)
setAllActiveJointValue
std::vector< Name > getAllActiveJointComponentName()
getAllActiveJointComponentName
Name getComponentActuatorName(Name component_name)
getComponentActuatorName
std::vector< JointValue > getAllJointValue()
getAllJointValue
Eigen::Vector3d getComponentCenterOfMass(Name component_name)
getComponentCenterOfMass
double getJointEffort(Name component_name)
getJointEffort
std::map< Name, Component > getAllComponent()
getAllComponent
void setWorldAngularVelocity(Eigen::Vector3d world_angular_velocity)
setWorldAngularVelocity
DynamicPose getComponentDynamicPoseFromWorld(Name component_name)
getComponentDynamicPoseFromWorld
std::vector< Name > getComponentChildName(Name component_name)
getComponentChildName
void setWorldLinearAcceleration(Eigen::Vector3d world_linear_acceleration)
setWorldLinearAcceleration
Name findComponentNameUsingId(int8_t id)
findComponentNameUsingId
void setJointPosition(Name name, double position)
setJointPosition
KinematicPose getWorldKinematicPose()
getWorldKinematicPose
void setAllActiveJointPosition(std::vector< double > joint_position_vector)
setAllActiveJointPosition
std::map< Name, Component >::iterator getIteratorEnd()
getIteratorEnd
std::vector< uint8_t > getAllActiveJointID()
getAllActiveJointID
void println(STRING str, STRING color="DEFAULT")
println
Eigen::Vector3d getComponentRelativePositionFromParent(Name component_name)
getComponentRelativePositionFromParent
void setJointAcceleration(Name name, double acceleration)
setJointAcceleration
void setComponent(Name component_name, Component component)
setComponent
void setComponentOrientationFromWorld(Name component_name, Eigen::Matrix3d orientation_to_wolrd)
setComponentOrientationFromWorld
void setComponentActuatorName(Name component_name, Name actuator_name)
setComponentActuatorName
double getJointVelocity(Name component_name)
getJointVelocity
Pose getComponentPoseFromWorld(Name component_name)
getComponentPoseFromWorld
void setAllJointPosition(std::vector< double > joint_position_vector)
setAllJointPosition
JointValue getJointValue(Name component_name)
getJointValue
std::map< Name, Component >::iterator getIteratorBegin()
getIteratorBegin
std::vector< double > getAllToolPosition()
getAllToolPosition
Eigen::Vector3d getComponentPositionFromWorld(Name component_name)
getComponentPositionFromWorld
Name getComponentParentName(Name component_name)
getComponentParentName
void print_vector(std::vector< T > &vec, uint8_t decimal_point=3)
print_vector
double getJointPosition(Name component_name)
getJointPosition
void print(STRING str, STRING color="DEFAULT")
print
void setWorldDynamicPose(DynamicPose world_dynamic_pose)
setWorldDynamicPose
Eigen::Matrix3d getComponentOrientationFromWorld(Name component_name)
getComponentOrientationFromWorld
bool checkComponentType(Name component_name, ComponentType component_type)
checkComponentType
std::vector< double > getAllJointPosition()
getAllJointPosition
bool checkJointLimit(Name Component_name, double value)
checkJointLimit
Component getComponent(Name component_name)
getComponent
void addTool(Name my_name, Name parent_name, Eigen::Vector3d relative_position, Eigen::Matrix3d relative_orientation, int8_t tool_id=-1, double max_position_limit=M_PI, double min_position_limit=-M_PI, double coefficient=1.0, double mass=0.0, Eigen::Matrix3d inertia_tensor=Eigen::Matrix3d::Identity(), Eigen::Vector3d center_of_mass=Eigen::Vector3d::Zero())
addTool
KinematicPose getComponentKinematicPoseFromWorld(Name component_name)
getComponentKinematicPoseFromWorld
void setWorldAngularAcceleration(Eigen::Vector3d world_angular_acceleration)
setWorldAngularAcceleration
DynamicPose getWorldDynamicPose()
getWorldDynamicPose
void addWorld(Name world_name, Name child_name, Eigen::Vector3d world_position=Eigen::Vector3d::Zero(), Eigen::Matrix3d world_orientation=Eigen::Matrix3d::Identity())
addWorld
std::vector< Name > getAllToolComponentName()
getAllToolComponentName
std::vector< JointValue > getAllToolValue()
getAllToolValue
Eigen::Matrix3d getComponentRelativeOrientationFromParent(Name component_name)
getComponentRelativeOrientationFromParent
void setWorldOrientation(Eigen::Matrix3d world_orientation)
setWorldOrientation
void addJoint(Name my_name, Name parent_name, Name child_name, Eigen::Vector3d relative_position, Eigen::Matrix3d relative_orientation, Eigen::Vector3d axis_of_rotation=Eigen::Vector3d::Zero(), int8_t joint_actuator_id=-1, double max_position_limit=M_PI, double min_position_limit=-M_PI, double coefficient=1.0, double mass=0.0, Eigen::Matrix3d inertia_tensor=Eigen::Matrix3d::Identity(), Eigen::Vector3d center_of_mass=Eigen::Vector3d::Zero())
addJoint
std::vector< double > getAllActiveJointPosition()
getAllActiveJointPosition
void setWorldPosition(Eigen::Vector3d world_position)
setWorldPosition
Eigen::Vector3d getWorldPosition()
getWorldPosition
void setComponentPositionFromWorld(Name component_name, Eigen::Vector3d position_to_world)
setComponentPositionFromWorld
double getJointAcceleration(Name component_name)
getJointAcceleration
Eigen::Vector3d getAxis(Name component_name)
getAxis
void setWorldLinearVelocity(Eigen::Vector3d world_linear_velocity)
setWorldLinearVelocity
double getComponentMass(Name component_name)
getComponentMass
void setJointEffort(Name name, double effort)
setJointEffort
void setJointVelocity(Name name, double velocity)
setJointVelocity
void setWorldPose(Pose world_pose)
setWorldPose
std::string STRING
void addComponentChild(Name my_name, Name child_name)
addComponentChild
void setJointValue(Name name, JointValue joint_value)
setJointValue
void print_matrix(matrix &m, uint8_t decimal_point=3)
print_matrix