@@ -65,8 +65,7 @@ bool TrajectoryPointInterface::writeMotionPrimitive(const std::shared_ptr<contro
65
65
{
66
66
return false ;
67
67
}
68
- uint8_t buffer[sizeof (int32_t ) * MESSAGE_LENGTH];
69
- uint8_t * b_pos = buffer;
68
+ std::array<int32_t , MESSAGE_LENGTH> buffer;
70
69
71
70
vector6d_t positions;
72
71
@@ -85,7 +84,7 @@ bool TrajectoryPointInterface::writeMotionPrimitive(const std::shared_ptr<contro
85
84
movel_primitive->target_pose .rx , movel_primitive->target_pose .ry , movel_primitive->target_pose .rz };
86
85
break ;
87
86
}
88
- case urcl::control:: MotionType::MOVEP:
87
+ case MotionType::MOVEP:
89
88
{
90
89
auto movep_primitive = std::static_pointer_cast<control::MovePPrimitive>(primitive);
91
90
positions = { movep_primitive->target_pose .x , movep_primitive->target_pose .y , movep_primitive->target_pose .z ,
@@ -96,41 +95,42 @@ bool TrajectoryPointInterface::writeMotionPrimitive(const std::shared_ptr<contro
96
95
throw UnsupportedMotionType ();
97
96
}
98
97
98
+ size_t index = 0 ;
99
99
for (auto const & pos : positions)
100
100
{
101
101
int32_t val = static_cast <int32_t >(round (pos * MULT_JOINTSTATE));
102
- val = htobe32 (val);
103
- b_pos += append (b_pos, val) ;
102
+ buffer[ index ] = htobe32 (val);
103
+ index ++ ;
104
104
}
105
105
for (size_t i = 0 ; i < positions.size (); ++i)
106
106
{
107
107
int32_t val = static_cast <int32_t >(round (primitive->velocity * MULT_JOINTSTATE));
108
- val = htobe32 (val);
109
- b_pos += append (b_pos, val) ;
108
+ buffer[ index ] = htobe32 (val);
109
+ index ++ ;
110
110
}
111
111
for (size_t i = 0 ; i < positions.size (); ++i)
112
112
{
113
113
int32_t val = static_cast <int32_t >(round (primitive->acceleration * MULT_JOINTSTATE));
114
- val = htobe32 (val);
115
- b_pos += append (b_pos, val) ;
114
+ buffer[ index ] = htobe32 (val);
115
+ index ++ ;
116
116
}
117
117
118
118
int32_t val = static_cast <int32_t >(round (primitive->duration .count () * MULT_TIME));
119
- val = htobe32 (val);
120
- b_pos += append (b_pos, val) ;
119
+ buffer[ index ] = htobe32 (val);
120
+ index ++ ;
121
121
122
122
val = static_cast <int32_t >(round (primitive->blend_radius * MULT_TIME));
123
- val = htobe32 (val);
124
- b_pos += append (b_pos, val) ;
123
+ buffer[ index ] = htobe32 (val);
124
+ index ++ ;
125
125
126
126
val = static_cast <int32_t >(primitive->type );
127
-
128
- val = htobe32 (val);
129
- b_pos += append (b_pos, val);
127
+ buffer[index ] = htobe32 (val);
128
+ index ++;
130
129
131
130
size_t written;
132
131
133
- return server_.write (client_fd_, buffer, sizeof (buffer), written);
132
+ // We stored the data in a int32_t vector, but write needs a uint8_t buffer
133
+ return server_.write (client_fd_, (uint8_t *)buffer.data (), buffer.size () * sizeof (int32_t ), written);
134
134
}
135
135
136
136
bool TrajectoryPointInterface::writeTrajectoryPoint (const vector6d_t * positions, const float acceleration,
0 commit comments