28
28
29
29
#include < ur_client_library/control/trajectory_point_interface.h>
30
30
#include < ur_client_library/exceptions.h>
31
+ #include < math.h>
31
32
32
33
namespace urcl
33
34
{
@@ -51,7 +52,7 @@ bool TrajectoryPointInterface::writeTrajectoryPoint(const vector6d_t* positions,
51
52
{
52
53
for (auto const & pos : *positions)
53
54
{
54
- int32_t val = static_cast <int32_t >(pos * MULT_JOINTSTATE);
55
+ int32_t val = static_cast <int32_t >(round ( pos * MULT_JOINTSTATE) );
55
56
val = htobe32 (val);
56
57
b_pos += append (b_pos, val);
57
58
}
@@ -65,11 +66,11 @@ bool TrajectoryPointInterface::writeTrajectoryPoint(const vector6d_t* positions,
65
66
b_pos += 6 * sizeof (int32_t );
66
67
b_pos += 6 * sizeof (int32_t );
67
68
68
- int32_t val = static_cast <int32_t >(goal_time * MULT_TIME);
69
+ int32_t val = static_cast <int32_t >(round ( goal_time * MULT_TIME) );
69
70
val = htobe32 (val);
70
71
b_pos += append (b_pos, val);
71
72
72
- val = static_cast <int32_t >(blend_radius * MULT_TIME);
73
+ val = static_cast <int32_t >(round ( blend_radius * MULT_TIME) );
73
74
val = htobe32 (val);
74
75
b_pos += append (b_pos, val);
75
76
@@ -107,7 +108,7 @@ bool TrajectoryPointInterface::writeTrajectorySplinePoint(const vector6d_t* posi
107
108
{
108
109
for (auto const & pos : *positions)
109
110
{
110
- int32_t val = static_cast <int32_t >(pos * MULT_JOINTSTATE);
111
+ int32_t val = static_cast <int32_t >(round ( pos * MULT_JOINTSTATE) );
111
112
val = htobe32 (val);
112
113
b_pos += append (b_pos, val);
113
114
}
@@ -123,7 +124,7 @@ bool TrajectoryPointInterface::writeTrajectorySplinePoint(const vector6d_t* posi
123
124
spline_type = control::TrajectorySplineType::SPLINE_CUBIC;
124
125
for (auto const & vel : *velocities)
125
126
{
126
- int32_t val = static_cast <int32_t >(vel * MULT_JOINTSTATE);
127
+ int32_t val = static_cast <int32_t >(round ( vel * MULT_JOINTSTATE) );
127
128
val = htobe32 (val);
128
129
b_pos += append (b_pos, val);
129
130
}
@@ -139,7 +140,7 @@ bool TrajectoryPointInterface::writeTrajectorySplinePoint(const vector6d_t* posi
139
140
spline_type = control::TrajectorySplineType::SPLINE_QUINTIC;
140
141
for (auto const & acc : *accelerations)
141
142
{
142
- int32_t val = static_cast <int32_t >(acc * MULT_JOINTSTATE);
143
+ int32_t val = static_cast <int32_t >(round ( acc * MULT_JOINTSTATE) );
143
144
val = htobe32 (val);
144
145
b_pos += append (b_pos, val);
145
146
}
@@ -149,7 +150,7 @@ bool TrajectoryPointInterface::writeTrajectorySplinePoint(const vector6d_t* posi
149
150
b_pos += 6 * sizeof (int32_t );
150
151
}
151
152
152
- int32_t val = static_cast <int32_t >(goal_time * MULT_TIME);
153
+ int32_t val = static_cast <int32_t >(round ( goal_time * MULT_TIME) );
153
154
val = htobe32 (val);
154
155
b_pos += append (b_pos, val);
155
156
0 commit comments