31 double theta,
double d,
double a,
double alpha,
bool is_prismatic)
37 void CKinematicChain::removeLink(
const size_t idx)
40 m_links.erase(m_links.begin() + idx);
68 void CKinematicChain::writeToStream(
75 out << m_links << m_origin;
106 void CKinematicChain::recomputeAllPoses(
111 const size_t N = m_links.size();
119 for (
size_t i = 0; i < N; i++)
122 const double th = m_links[i].theta;
123 const double alpha = m_links[i].alpha;
124 const double d = m_links[i].d;
125 const double a = m_links[i].a;
127 const double t_vals[3] = {
a * cos(th),
a * sin(th), d};
128 const double r_vals[3 * 3] = {cos(th),
129 -sin(th) * cos(
alpha),
130 sin(th) * sin(
alpha),
132 cos(th) * cos(
alpha),
133 -cos(th) * sin(
alpha),
143 p.composeFrom(
p, link);
149 const float R = 0.01f;
154 mrpt::make_aligned_shared<mrpt::opengl::CCylinder>(
R,
R, d);
156 gl_cyl->setName(
"cyl.d");
158 objs->insert(gl_cyl);
164 mrpt::make_aligned_shared<mrpt::opengl::CCylinder>(
R,
R, -
a);
167 gl_cyl2->setName(
"cyl.a");
169 objs->insert(gl_cyl2);
172 void CKinematicChain::getAs3DObject(
178 const size_t N = m_links.size();
182 recomputeAllPoses(all_poses);
184 m_last_gl_objects.resize(N + 1);
187 for (
size_t i = 0; i <= N; i++)
191 gl_corner->setPose(all_poses[i]);
193 gl_corner->setName(
mrpt::format(
"%u", static_cast<unsigned int>(i)));
194 gl_corner->enableShowName();
196 if (i < N)
addBar_D(gl_corner, m_links[i].d);
197 if (i > 0)
addBar_A(gl_corner, m_links[i - 1].
a);
199 obj->insert(gl_corner);
200 m_last_gl_objects[i] = gl_corner;
203 if (out_all_poses) out_all_poses->swap(all_poses);
206 void CKinematicChain::update3DObject(
211 (m_links.size() + 1) == m_last_gl_objects.size(),
212 "The kinematic chain has changed since the last call to " 215 const size_t N = m_links.size();
219 recomputeAllPoses(all_poses);
221 for (
size_t i = 0; i <= N; i++)
225 m_last_gl_objects[i]);
226 gl_objs->
setPose(all_poses[i]);
232 gl_objs->getByName(
"cyl.d"));
233 const double d = m_links[i].d;
241 gl_objs->getByName(
"cyl.a"));
242 const double a = m_links[i - 1].a;
248 if (out_all_poses) out_all_poses->swap(all_poses);
255 m_last_gl_objects.clear();
GLclampf GLclampf GLclampf alpha
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A set of object, which are referenced to the coordinates framework established in this object...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void addBar_A(mrpt::opengl::CSetOfObjects::Ptr &objs, const double a)
#define ASSERT_BELOW_(__A, __B)
GLsizei GLsizei GLuint * obj
mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, TKinematicLink &o)
void clear()
Clear the contents of this container.
double d
Distance along Z_i to the common normal between Z_i and Z_{i+1}.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
This base provides a set of functions for maths stuff.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
bool is_prismatic
"false": Is revolute ("q_i" is "theta"), "true": is prismatic ("q_i" is "d")
std::shared_ptr< CCylinder > Ptr
A cylinder or cone whose base lies in the XY plane.
std::shared_ptr< CSetOfObjects > Ptr
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void addBar_D(mrpt::opengl::CSetOfObjects::Ptr &objs, const double d)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double alpha
Rotation along X_{i+1} to transform Z_i into Z_{i+1}.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
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...
CRenderizable & setPose(const mrpt::poses::CPose3D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
double theta
Rotation from X_i to X_{i+1} (radians)
double a
Distance along the common normal (in the same direction than the new X_{i+1})
void setHeight(float height)
Chenges cylinder's height.
unsigned __int32 uint32_t
A open-loop kinematic chain model, suitable to robotic manipulators.
#define ASSERTMSG_(f, __ERROR_MSG)
GLubyte GLubyte GLubyte a
std::vector< TYPE1, Eigen::aligned_allocator< TYPE1 > > vector_t
mrpt::utils::CStream & operator<<(mrpt::utils::CStream &out, const TKinematicLink &o)
An individual kinematic chain element (one link) which builds up a CKinematicChain.