Go to the documentation of this file.
30 double theta,
double d,
double a,
double alpha,
bool is_prismatic)
36 void CKinematicChain::removeLink(
const size_t idx)
39 m_links.erase(m_links.begin() + idx);
64 uint8_t CKinematicChain::serializeGetVersion()
const {
return 1; }
67 out << m_links << m_origin;
70 void CKinematicChain::serializeFrom(
95 void CKinematicChain::recomputeAllPoses(
100 const size_t N = m_links.size();
108 for (
size_t i = 0; i < N; i++)
111 const double th = m_links[i].theta;
112 const double alpha = m_links[i].alpha;
113 const double d = m_links[i].d;
114 const double a = m_links[i].a;
116 const double t_vals[3] = {
a * cos(th),
a * sin(th), d};
117 const double r_vals[3 * 3] = {cos(th),
118 -sin(th) * cos(
alpha),
119 sin(th) * sin(
alpha),
121 cos(th) * cos(
alpha),
122 -cos(th) * sin(
alpha),
132 p.composeFrom(
p, link);
138 const float R = 0.01f;
143 mrpt::make_aligned_shared<mrpt::opengl::CCylinder>(
R,
R, d);
145 gl_cyl->setName(
"cyl.d");
147 objs->insert(gl_cyl);
153 mrpt::make_aligned_shared<mrpt::opengl::CCylinder>(
R,
R, -
a);
156 gl_cyl2->setName(
"cyl.a");
158 objs->insert(gl_cyl2);
161 void CKinematicChain::getAs3DObject(
166 const size_t N = m_links.size();
170 recomputeAllPoses(all_poses);
172 m_last_gl_objects.resize(N + 1);
175 for (
size_t i = 0; i <= N; i++)
179 gl_corner->setPose(all_poses[i]);
181 gl_corner->setName(
mrpt::format(
"%u",
static_cast<unsigned int>(i)));
182 gl_corner->enableShowName();
184 if (i < N)
addBar_D(gl_corner, m_links[i].d);
185 if (i > 0)
addBar_A(gl_corner, m_links[i - 1].
a);
187 obj->insert(gl_corner);
188 m_last_gl_objects[i] = gl_corner;
191 if (out_all_poses) out_all_poses->swap(all_poses);
194 void CKinematicChain::update3DObject(
198 (m_links.size() + 1) == m_last_gl_objects.size(),
199 "The kinematic chain has changed since the last call to "
202 const size_t N = m_links.size();
206 recomputeAllPoses(all_poses);
208 for (
size_t i = 0; i <= N; i++)
211 std::dynamic_pointer_cast<mrpt::opengl::CSetOfObjects>(
212 m_last_gl_objects[i]);
213 gl_objs->setPose(all_poses[i]);
218 std::dynamic_pointer_cast<mrpt::opengl::CCylinder>(
219 gl_objs->getByName(
"cyl.d"));
220 const double d = m_links[i].d;
227 std::dynamic_pointer_cast<mrpt::opengl::CCylinder>(
228 gl_objs->getByName(
"cyl.a"));
229 const double a = m_links[i - 1].a;
231 glCyl2->setHeight(-
a);
235 if (out_all_poses) out_all_poses->swap(all_poses);
242 m_last_gl_objects.clear();
double a
Distance along the common normal (in the same direction than the new X_{i+1})
void clear()
Clear the contents of this container.
double theta
Rotation from X_i to X_{i+1} (radians)
A open-loop kinematic chain model, suitable to robotic manipulators.
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &out, const TKinematicLink &o)
bool is_prismatic
"false": Is revolute ("q_i" is "theta"), "true": is prismatic ("q_i" is "d")
GLsizei GLsizei GLuint * obj
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
std::shared_ptr< CCylinder > Ptr
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double d
Distance along Z_i to the common normal between Z_i and Z_{i+1}.
#define ASSERT_(f)
Defines an assertion mechanism.
CSetOfObjects::Ptr CornerXYZSimple(float scale=1.0, float lineWidth=1.0)
Returns three arrows representing a X,Y,Z 3D corner (just thick lines instead of complex arrows for f...
GLclampf GLclampf GLclampf alpha
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Virtual base class for "archives": classes abstracting I/O streams.
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
#define ASSERT_BELOW_(__A, __B)
void addBar_D(mrpt::opengl::CSetOfObjects::Ptr &objs, const double d)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
std::shared_ptr< CSetOfObjects > Ptr
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
double alpha
Rotation along X_{i+1} to transform Z_i into Z_{i+1}.
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, TKinematicLink &o)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
void addBar_A(mrpt::opengl::CSetOfObjects::Ptr &objs, const double a)
This base provides a set of functions for maths stuff.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
An individual kinematic chain element (one link) which builds up a CKinematicChain.
unsigned __int32 uint32_t
GLubyte GLubyte GLubyte a
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |