moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
joint_model_group.cpp
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2022, Peter David Fagan
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of PickNik Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: Peter David Fagan */
36
37#include "joint_model_group.hpp"
38#include <exception>
39
40namespace moveit_py
41{
42namespace bind_robot_model
43{
44bool satisfiesPositionBounds(const moveit::core::JointModelGroup* jmg, const Eigen::VectorXd& joint_positions,
45 const double margin)
46{
47 assert(joint_positions.size() == jmg->getActiveVariableCount());
48 return jmg->satisfiesPositionBounds(joint_positions.data(), margin);
49}
50
51void initJointModelGroup(py::module& m)
52{
53 py::module robot_model = m.def_submodule("robot_model");
54
55 py::class_<moveit::core::JointModelGroup>(robot_model, "JointModelGroup",
56 R"(
57 Representation of a group of joints that are part of a robot model.
58 )")
59
60 .def_property("name", &moveit::core::JointModelGroup::getName, nullptr,
61 R"(
62 str: The name of the joint model group.
63 )")
64
65 .def_property_readonly("link_model_names", &moveit::core::JointModelGroup::getLinkModelNames)
66 .def_property("joint_model_names", &moveit::core::JointModelGroup::getJointModelNames, nullptr,
67 R"(
68 list[str]: The names of the joint models in the group.
69 )")
70 .def_property("active_joint_model_names", &moveit::core::JointModelGroup::getActiveJointModelNames, nullptr)
71 .def_property("active_joint_model_bounds", &moveit::core::JointModelGroup::getActiveJointModelsBounds, nullptr,
72 py::return_value_policy::reference_internal)
73 .def_property_readonly("eef_name",
74 [](const moveit::core::JointModelGroup* self) {
75 const auto eef = self->getOnlyOneEndEffectorTip();
76 if (!eef)
77 {
78 throw std::runtime_error("Error getting the end effector name - see log for details");
79 }
80 return eef->getName();
81 })
82 .def("satisfies_position_bounds", &moveit_py::bind_robot_model::satisfiesPositionBounds, py::arg("values"),
83 py::arg("margin") = 0.0);
84}
85} // namespace bind_robot_model
86} // namespace moveit_py
const JointBoundsVector & getActiveJointModelsBounds() const
Get the bounds for all the active joints.
const std::vector< std::string > & getActiveJointModelNames() const
Get the names of the active joints in this group. These are the names of the joints returned by getJo...
const std::vector< std::string > & getJointModelNames() const
Get the names of the joints in this group. These are the names of the joints returned by getJointMode...
const std::string & getName() const
Get the name of the joint group.
const moveit::core::LinkModel * getOnlyOneEndEffectorTip() const
Get one end effector tip, throwing an error if there ends up being more in the joint model group This...
bool satisfiesPositionBounds(const double *state, double margin=0.0) const
const std::vector< std::string > & getLinkModelNames() const
Get the names of the links that are part of this joint group.
unsigned int getActiveVariableCount() const
Get the number of variables that describe the active joints in this joint group. This excludes variab...
void initJointModelGroup(py::module &m)
bool satisfiesPositionBounds(const moveit::core::JointModelGroup *jmg, const Eigen::VectorXd &joint_positions, const double margin)