Skip to content

Commit 2bf48be

Browse files
committed
Use MotionType in trajectory point interface
This removes code duplication
1 parent 87fd042 commit 2bf48be

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

doc/architecture/trajectory_point_interface.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ representations in 21 datafields. The data fields have the following meaning:
4242
0-5 trajectory point positions (floating point)
4343
6-11 trajectory point velocities (floating point)
4444
12-17 trajectory point accelerations (floating point)
45-
18 trajectory point type (0: JOINT, 1: CARTESIAN, 2: JOINT_SPLINE)
45+
18 trajectory point type (0: MOVEJ, 1: MOVEL, 51: SPLINE)
4646
19 trajectory point time (in seconds, floating point)
4747
20 depending on trajectory point type
4848

49-
- JOINT, CARTESIAN: point blend radius (in meters, floating point)
50-
- JOINT_SPLINE: spline type (1: CUBIC, 2: QUINTIC)
49+
- MOVEJ, MOVEL: point blend radius (in meters, floating point)
50+
- SPLINE: spline type (1: CUBIC, 2: QUINTIC)
5151
===== =====

include/ur_client_library/control/trajectory_point_interface.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ enum class TrajectorySplineType : int32_t
6363
SPLINE_QUINTIC = 2
6464
};
6565

66-
/*!
67-
* Motion Types
68-
*/
69-
enum class TrajectoryMotionType : int32_t
70-
{
71-
JOINT_POINT = 0,
72-
CARTESIAN_POINT = 1,
73-
JOINT_POINT_SPLINE = 2
74-
};
75-
7666
/*!
7767
* \brief The TrajectoryPointInterface class handles trajectory forwarding to the robot. Full
7868
* trajectories are forwarded to the robot controller and are executed there.

resources/external_control.urscript

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ REVERSE_INTERFACE_DATA_DIMENSION = 8
3131
TRAJECTORY_MODE_RECEIVE = 1
3232
TRAJECTORY_MODE_CANCEL = -1
3333

34-
TRAJECTORY_POINT_JOINT = 0
35-
TRAJECTORY_POINT_CARTESIAN = 1
36-
TRAJECTORY_POINT_JOINT_SPLINE = 2
34+
MOTION_TYPE_MOVEJ = 0
35+
MOTION_TYPE_MOVEL = 1
36+
MOTION_TYPE_SPLINE = 51
3737
TRAJECTORY_DATA_DIMENSION = 3 * 6 + 1
3838

3939
TRAJECTORY_RESULT_SUCCESS = 0
@@ -486,7 +486,7 @@ thread trajectoryThread():
486486
is_last_point = True
487487
end
488488
# MoveJ point
489-
if raw_point[INDEX_POINT_TYPE] == TRAJECTORY_POINT_JOINT:
489+
if raw_point[INDEX_POINT_TYPE] == MOTION_TYPE_MOVEJ:
490490
acceleration = raw_point[13] / MULT_jointstate
491491
velocity = raw_point[7] / MULT_jointstate
492492
movej(q, a = acceleration, v = velocity, t = tmptime, r = blend_radius)
@@ -496,7 +496,7 @@ thread trajectoryThread():
496496
spline_qd = [0, 0, 0, 0, 0, 0]
497497

498498
# Movel point
499-
elif raw_point[INDEX_POINT_TYPE] == TRAJECTORY_POINT_CARTESIAN:
499+
elif raw_point[INDEX_POINT_TYPE] == MOTION_TYPE_MOVEL:
500500
acceleration = raw_point[13] / MULT_jointstate
501501
velocity = raw_point[7] / MULT_jointstate
502502
movel(p[q[0], q[1], q[2], q[3], q[4], q[5]], a = acceleration, v = velocity, t = tmptime, r = blend_radius)
@@ -506,7 +506,7 @@ thread trajectoryThread():
506506
spline_qd = [0, 0, 0, 0, 0, 0]
507507

508508
# Joint spline point
509-
elif raw_point[INDEX_POINT_TYPE] == TRAJECTORY_POINT_JOINT_SPLINE:
509+
elif raw_point[INDEX_POINT_TYPE] == MOTION_TYPE_SPLINE:
510510

511511
# Cubic spline
512512
if raw_point[INDEX_SPLINE_TYPE] == SPLINE_CUBIC:

src/control/trajectory_point_interface.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <math.h>
3232
#include <stdexcept>
3333
#include "ur_client_library/comm/socket_t.h"
34+
#include "ur_client_library/control/motion_primitives.h"
3435

3536
namespace urcl
3637
{
@@ -105,11 +106,11 @@ bool TrajectoryPointInterface::writeTrajectoryPoint(const vector6d_t* positions,
105106

106107
if (cartesian)
107108
{
108-
val = static_cast<int32_t>(control::TrajectoryMotionType::CARTESIAN_POINT);
109+
val = static_cast<int32_t>(control::MotionType::MOVEL);
109110
}
110111
else
111112
{
112-
val = static_cast<int32_t>(control::TrajectoryMotionType::JOINT_POINT);
113+
val = static_cast<int32_t>(control::MotionType::MOVEJ);
113114
}
114115

115116
val = htobe32(val);
@@ -193,7 +194,7 @@ bool TrajectoryPointInterface::writeTrajectorySplinePoint(const vector6d_t* posi
193194
val = htobe32(val);
194195
b_pos += append(b_pos, val);
195196

196-
val = static_cast<int32_t>(control::TrajectoryMotionType::JOINT_POINT_SPLINE);
197+
val = static_cast<int32_t>(control::MotionType::SPLINE);
197198
val = htobe32(val);
198199
b_pos += append(b_pos, val);
199200

tests/test_trajectory_point_interface.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <gtest/gtest.h>
3232
#include <ur_client_library/control/trajectory_point_interface.h>
3333
#include <ur_client_library/comm/tcp_socket.h>
34+
#include <ur_client_library/control/motion_primitives.h>
3435

3536
using namespace urcl;
3637

@@ -283,7 +284,7 @@ TEST_F(TrajectoryPointInterfaceTest, write_quintic_joint_spline)
283284
received_data.blend_radius_or_spline_type);
284285

285286
// Motion type
286-
EXPECT_EQ(static_cast<int32_t>(control::TrajectoryMotionType::JOINT_POINT_SPLINE), received_data.motion_type);
287+
EXPECT_EQ(static_cast<int32_t>(control::MotionType::SPLINE), received_data.motion_type);
287288
}
288289

289290
TEST_F(TrajectoryPointInterfaceTest, write_cubic_joint_spline)
@@ -327,7 +328,7 @@ TEST_F(TrajectoryPointInterfaceTest, write_cubic_joint_spline)
327328
received_data.blend_radius_or_spline_type);
328329

329330
// Motion type
330-
EXPECT_EQ(static_cast<int32_t>(control::TrajectoryMotionType::JOINT_POINT_SPLINE), received_data.motion_type);
331+
EXPECT_EQ(static_cast<int32_t>(control::MotionType::SPLINE), received_data.motion_type);
331332
}
332333

333334
TEST_F(TrajectoryPointInterfaceTest, write_splines_velocities)
@@ -443,4 +444,4 @@ int main(int argc, char* argv[])
443444
::testing::InitGoogleTest(&argc, argv);
444445

445446
return RUN_ALL_TESTS();
446-
}
447+
}

0 commit comments

Comments
 (0)