2929#include < ur_client_library/control/trajectory_point_interface.h>
3030#include < ur_client_library/exceptions.h>
3131#include < math.h>
32+ #include < cstdint>
3233#include < stdexcept>
3334#include " ur_client_library/comm/socket_t.h"
3435#include " ur_client_library/control/motion_primitives.h"
@@ -91,6 +92,13 @@ bool TrajectoryPointInterface::writeMotionPrimitive(const std::shared_ptr<contro
9192 movep_primitive->target_pose .rx , movep_primitive->target_pose .ry , movep_primitive->target_pose .rz };
9293 break ;
9394 }
95+ case MotionType::MOVEC:
96+ {
97+ auto movec_primitive = std::static_pointer_cast<control::MoveCPrimitive>(primitive);
98+ positions = { movec_primitive->target_pose .x , movec_primitive->target_pose .y , movec_primitive->target_pose .z ,
99+ movec_primitive->target_pose .rx , movec_primitive->target_pose .ry , movec_primitive->target_pose .rz };
100+ break ;
101+ }
94102 default :
95103 throw UnsupportedMotionType ();
96104 }
@@ -102,17 +110,49 @@ bool TrajectoryPointInterface::writeMotionPrimitive(const std::shared_ptr<contro
102110 buffer[index] = htobe32 (val);
103111 index++;
104112 }
105- for (size_t i = 0 ; i < positions.size (); ++i)
113+
114+ if (primitive->type == MotionType::MOVEC)
106115 {
116+ auto movec_primitive = std::static_pointer_cast<control::MoveCPrimitive>(primitive);
117+ auto via = { movec_primitive->via_point_pose .x , movec_primitive->via_point_pose .y ,
118+ movec_primitive->via_point_pose .z , movec_primitive->via_point_pose .rx ,
119+ movec_primitive->via_point_pose .ry , movec_primitive->via_point_pose .rz };
120+ for (auto const & pos : via)
121+ {
122+ int32_t val = static_cast <int32_t >(round (pos * MULT_JOINTSTATE));
123+ buffer[index] = htobe32 (val);
124+ index++;
125+ }
107126 int32_t val = static_cast <int32_t >(round (primitive->velocity * MULT_JOINTSTATE));
108127 buffer[index] = htobe32 (val);
109128 index++;
110- }
111- for ( size_t i = 0 ; i < positions. size (); ++i)
112- {
113- int32_t val = static_cast <int32_t >(round (primitive-> acceleration * MULT_JOINTSTATE ));
129+ val = static_cast < int32_t >( round (primitive-> acceleration * MULT_JOINTSTATE));
130+ buffer[index] = htobe32 (val);
131+ index++;
132+ val = static_cast <int32_t >(round (movec_primitive-> mode ));
114133 buffer[index] = htobe32 (val);
115134 index++;
135+ for (size_t i = 0 ; i < positions.size () - 3 ; ++i)
136+ {
137+ int32_t val = 0 ;
138+ buffer[index] = htobe32 (val);
139+ index++;
140+ }
141+ }
142+ else
143+ {
144+ for (size_t i = 0 ; i < positions.size (); ++i)
145+ {
146+ int32_t val = static_cast <int32_t >(round (primitive->velocity * MULT_JOINTSTATE));
147+ buffer[index] = htobe32 (val);
148+ index++;
149+ }
150+ for (size_t i = 0 ; i < positions.size (); ++i)
151+ {
152+ int32_t val = static_cast <int32_t >(round (primitive->acceleration * MULT_JOINTSTATE));
153+ buffer[index] = htobe32 (val);
154+ index++;
155+ }
116156 }
117157
118158 int32_t val = static_cast <int32_t >(round (primitive->duration .count () * MULT_TIME));
@@ -283,4 +323,4 @@ void TrajectoryPointInterface::messageCallback(const socket_t filedescriptor, ch
283323 }
284324}
285325} // namespace control
286- } // namespace urcl
326+ } // namespace urcl
0 commit comments