29
29
#include < ur_client_library/control/trajectory_point_interface.h>
30
30
#include < ur_client_library/exceptions.h>
31
31
#include < math.h>
32
+ #include < cstdint>
32
33
#include < stdexcept>
33
34
#include " ur_client_library/comm/socket_t.h"
34
35
#include " ur_client_library/control/motion_primitives.h"
@@ -91,6 +92,13 @@ bool TrajectoryPointInterface::writeMotionPrimitive(const std::shared_ptr<contro
91
92
movep_primitive->target_pose .rx , movep_primitive->target_pose .ry , movep_primitive->target_pose .rz };
92
93
break ;
93
94
}
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
+ }
94
102
default :
95
103
throw UnsupportedMotionType ();
96
104
}
@@ -102,17 +110,49 @@ bool TrajectoryPointInterface::writeMotionPrimitive(const std::shared_ptr<contro
102
110
buffer[index ] = htobe32 (val);
103
111
index ++;
104
112
}
105
- for (size_t i = 0 ; i < positions.size (); ++i)
113
+
114
+ if (primitive->type == MotionType::MOVEC)
106
115
{
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
+ }
107
126
int32_t val = static_cast <int32_t >(round (primitive->velocity * MULT_JOINTSTATE));
108
127
buffer[index ] = htobe32 (val);
109
128
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 ));
114
133
buffer[index ] = htobe32 (val);
115
134
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
+ }
116
156
}
117
157
118
158
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
283
323
}
284
324
}
285
325
} // namespace control
286
- } // namespace urcl
326
+ } // namespace urcl
0 commit comments