Skip to content

Commit 731d943

Browse files
authored
Merge pull request #290 from compas-dev/trajectory_data
Fix JointTrajectoryPoint serialization
2 parents 7ac9f88 + 2b8751b commit 731d943

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ Unreleased
2020

2121
**Fixed**
2222

23-
* Fix ``repr()`` of ``ROSmsg`` class
24-
* Fix data type of secs and nsecs in ``Time`` ROS message
25-
* Fix ``CollisionObject.to_collision_meshes``
23+
* Fixed ``repr()`` of ``ROSmsg`` class
24+
* Fixed data type of secs and nsecs in ``Time`` ROS message
25+
* Fixed ``CollisionObject.to_collision_meshes``
26+
* Fixed serialization of joint names for ``compas_fab.robots.JointTrajectoryPoint``
2627

2728
**Deprecated**
2829

src/compas_fab/robots/trajectory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def data(self):
146146
def data(self, data):
147147
self._joint_values = FixedLengthList(data.get('joint_values') or [])
148148
self._joint_types = FixedLengthList(data.get('joint_types') or [])
149+
self._joint_names = FixedLengthList(data.get('joint_names') or [])
149150
self._velocities = FixedLengthList(data.get('velocities') or [])
150151
self._accelerations = FixedLengthList(data.get('accelerations') or [])
151152
self._effort = FixedLengthList(data.get('effort') or [])

tests/robots/test_trajectory.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
from compas_fab.robots import JointTrajectoryPoint
88

99

10+
@pytest.fixture
11+
def jtp():
12+
return JointTrajectoryPoint([1.571, 0, 0, 0.262, 0, 0],
13+
[0] * 6,
14+
[3.] * 6,
15+
time_from_start=Duration(2, 1293),
16+
joint_names=['joint_1', 'joint_2', 'joint_3',
17+
'joint_4', 'joint_5', 'joint_6']
18+
)
19+
20+
1021
@pytest.fixture
1122
def trj():
1223
p1 = JointTrajectoryPoint([1.571, 0, 0, 0.262, 0, 0],
@@ -30,10 +41,18 @@ def test_trajectory_points(trj):
3041
assert(len(trj.points) == 2)
3142

3243

44+
def test_joint_trajectory_point_serialization(jtp):
45+
data = jtp.to_data()
46+
new_jtp = JointTrajectoryPoint.from_data(data)
47+
assert new_jtp.to_data() == data
48+
assert new_jtp['joint_1'] == 1.571
49+
50+
3351
def test_serialization(trj):
3452
data = trj.to_data()
3553
new_trj = JointTrajectory.from_data(data)
3654
assert(new_trj.to_data() == data)
55+
assert(new_trj.time_from_start == Duration(6, 0).seconds)
3756

3857

3958
def test_joint_trajectory_point_merged():

0 commit comments

Comments
 (0)