36 void CKinematicChain::removeLink(
const size_t idx)
39 m_links.erase(m_links.begin()+idx);
73 out << m_links << m_origin;
105 const size_t N=m_links.size();
113 for (
size_t i=0;i<N;i++)
116 const double th = m_links[i].theta;
117 const double alpha = m_links[i].alpha;
118 const double d = m_links[i].d;
119 const double a = m_links[i].a;
121 const double t_vals[3] = {
125 const double r_vals[3*3] = {
126 cos(th), -sin(th)*cos(
alpha), sin(th)*sin(
alpha),
127 sin(th), cos(th)*cos(
alpha), -cos(th)*sin(
alpha),
135 p.composeFrom(
p,link);
141 const float R = 0.01f;
143 void addBar_D(mrpt::opengl::CSetOfObjectsPtr &objs,
const double d)
148 gl_cyl->setName(
"cyl.d");
150 objs->insert(gl_cyl);
153 void addBar_A(mrpt::opengl::CSetOfObjectsPtr &objs,
const double a)
158 gl_cyl2->setName(
"cyl.a");
160 objs->insert(gl_cyl2);
163 void CKinematicChain::getAs3DObject(
164 mrpt::opengl::CSetOfObjectsPtr &
obj,
169 const size_t N=m_links.size();
173 recomputeAllPoses( all_poses );
175 m_last_gl_objects.resize(N+1);
178 for (
size_t i=0;i<=N;i++)
181 gl_corner->setPose( all_poses[i] );
183 gl_corner->setName(
mrpt::format(
"%u",static_cast<unsigned int>(i)) );
184 gl_corner->enableShowName();
186 if (i<N)
addBar_D(gl_corner,m_links[i].d);
187 if (i>0)
addBar_A(gl_corner,m_links[i-1].
a);
189 obj->insert(gl_corner);
190 m_last_gl_objects[i] = gl_corner;
194 out_all_poses->swap(all_poses);
199 ASSERTMSG_((m_links.size()+1)==m_last_gl_objects.size(),
"The kinematic chain has changed since the last call to getAs3DObject()")
201 const size_t N=m_links.size();
205 recomputeAllPoses( all_poses );
207 for (
size_t i=0;i<=N;i++)
209 mrpt::opengl::CSetOfObjectsPtr gl_objs = mrpt::opengl::CSetOfObjectsPtr(m_last_gl_objects[i]);
210 gl_objs->setPose( all_poses[i] );
214 mrpt::opengl::CCylinderPtr glCyl = mrpt::opengl::CCylinderPtr( gl_objs->getByName(
"cyl.d") );
215 const double d = m_links[i].d;
216 glCyl->setHeight( d );
221 mrpt::opengl::CCylinderPtr glCyl2 = mrpt::opengl::CCylinderPtr( gl_objs->getByName(
"cyl.a") );
222 const double a = m_links[i-1].a;
224 glCyl2->setHeight( -
a );
229 out_all_poses->swap(all_poses);
236 m_last_gl_objects.clear();
GLclampf GLclampf GLclampf alpha
static CCylinderPtr Create()
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void addBar_A(mrpt::opengl::CSetOfObjectsPtr &objs, const double a)
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.
#define ASSERT_BELOW_(__A, __B)
GLsizei GLsizei GLuint * obj
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")
CSetOfObjectsPtr OPENGL_IMPEXP 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...
::mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CKinematicChainPtr &pObj)
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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}.
void addBar_D(mrpt::opengl::CSetOfObjectsPtr &objs, const double d)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
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})
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
KINEMATICS_IMPEXP mrpt::utils::CStream & operator<<(mrpt::utils::CStream &out, const TKinematicLink &o)
An individual kinematic chain element (one link) which builds up a CKinematicChain.