Skip to content

Commit

Permalink
Debugged
Browse files Browse the repository at this point in the history
  • Loading branch information
tetov committed Nov 3, 2020
1 parent c3bc371 commit 52279c2
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 42 deletions.
79 changes: 69 additions & 10 deletions grasshopper/create_run_data.ghx

Large diffs are not rendered by default.

184 changes: 179 additions & 5 deletions grasshopper/path_planning.ghx

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ ignore = D001

[pydocstyle]
convention = numpy
add-select = D212
add-ignore = D202,D105
add-ignore = D105,D202

[yapf]
COLUMN_LIMIT = 88
Expand Down
9 changes: 7 additions & 2 deletions src/rapid_clay_formations_fab/abb/abb_rcf_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def confirm_start(self):
self.send(compas_rrc.PrintText("Press play when ready."))
self.send(compas_rrc.Stop())

# After user presses play on pendant execution resumes:
self.send(compas_rrc.PrintText("Continuing execution."))

def ping(self, timeout=10):
"""Ping ABB robot controller.
Expand Down Expand Up @@ -260,15 +263,17 @@ def execute_trajectory(
"""
log.debug(f"Trajectory: {trajectory}")
kwargs = {}

if trajectory.trajectory_type == MinimalTrajectory.JOINT_TRAJECTORY:
trajectory_pts = trajectory.to_robot_joints()
trajectory_pts = trajectory.as_robot_joints_points()
instruction = MoveToJoints

elif trajectory.trajectory_type == MinimalTrajectory.FRAME_TRAJECTORY:
trajectory_pts = trajectory.points
trajectory_pts = trajectory
instruction = MoveToRobtarget
kwargs["motion_type"] = motion_type
else:
print(trajectory.trajectory_type)
raise RuntimeError("Trajectory not recognized: {}".format(trajectory))

for pt in trajectory_pts[:-1]: # skip last
Expand Down
26 changes: 16 additions & 10 deletions src/rapid_clay_formations_fab/fab_data/fabrication_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,24 @@ def __init__(
def data(self):
""":obj:`dict` : The data dictionary that represents the :class:`PlaceElement`.""" # noqa: E501
data = super(PlaceElement, self).data
data.update(
{
"compression_ratio": self.compression_ratio,
"travel_trajectories": self.travel_trajectories.to_data() or None,
"return_travel_trajectories": self.return_travel_trajectories.to_data()
or None,
"place_trajectories": self.place_trajectories.to_data() or None,
"return_place_trajectories": self.return_place_trajectories.to_data()
or None,
}
data["compression_ratio"] = self.compression_ratio

data["travel_trajectories"] = self.travel_trajectories

# optional trajectories
opt_traj_attrs = (
"return_travel_trajectories",
"place_trajectories",
"return_place_trajectories",
)

for attr in opt_traj_attrs:
# Get value of property attribute (ending with "_")
# Returns none if there is no value set explicitly
attr_value = getattr(self, attr + "_", None)
if attr_value:
data[attr] = attr_value.to_data()

return data

@data.setter
Expand Down
2 changes: 1 addition & 1 deletion src/rapid_clay_formations_fab/fab_data/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def load_fabrication_elements(path_or_dict):
"""
fab_data = _get_fab_data(path_or_dict)

if fab_data.get("compression_ratio"):
if fab_data[0].get("travel_trajectories"):
return [PlaceElement.from_data(data) for data in fab_data]

return [FabricationElement.from_data(data) for data in fab_data]
Expand Down
22 changes: 10 additions & 12 deletions src/rapid_clay_formations_fab/robots/trajectories.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from compas.geometry import Frame
from compas_fab.robots import Configuration
from compas_fab.robots import JointTrajectoryPoint
from compas_fab.robots import to_degrees
from compas_rrc import RobotJoints

Expand Down Expand Up @@ -159,26 +158,21 @@ def data(self):

@data.setter
def data(self, data):
print("Data: {}".format(data))
print("Type: {}".format(type(data)))
if data["points"][0].get("xaxis"): # check if data is of frame.data
self.points = [Frame.from_data(pt) for pt in data["points"]]
# check if first elem is JointTrajectoryPoint dict
elif data["points"][0].get("types"):
# check if first elem is Configuration dict
elif data["points"][0].get("values"):
self.points = [Configuration.from_data(pt) for pt in data["points"]]
else:
raise NotImplementedError(
"Object type not supported: {}".format(type(data[0]))
)

@property
def robot_joints_points(self):
""":obj:`list` of :class:`compas_rrc.RobotJoints` : Trajectory as list of ``RobotJoints``.""" # noqa: E501
return [RobotJoints(*to_degrees(pt)) for pt in self.points]
raise NotImplementedError("Object not recognized.")

@property
def trajectory_type(self):
""":obj:`type` : Return the type of elements in the trajectory."""
self._raise_if_mixed_types()
if isinstance(self[0], JointTrajectoryPoint):
if isinstance(self[0], Configuration):
return self.JOINT_TRAJECTORY
if isinstance(self[0], Frame):
return self.FRAME_TRAJECTORY
Expand All @@ -194,6 +188,10 @@ def _raise_if_mixed_types(self):
"Trajectory contains more than one type of objects: {}".format(types)
)

def as_robot_joints_points(self):
""":obj:`list` of :class:`compas_rrc.RobotJoints` : Trajectory as list of ``RobotJoints``.""" # noqa: E501
return [RobotJoints(*to_degrees(pt.values)) for pt in self.points]

def copy(self):
"""Get an independent copy of object."""
cls = type(self)
Expand Down

0 comments on commit 52279c2

Please sign in to comment.