forked from anenriquez/mrta_stn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from ropod-project/develop
End of project stable version
- Loading branch information
Showing
29 changed files
with
1,013 additions
and
577 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class NoSTPSolution(Exception): | ||
|
||
def __init__(self): | ||
""" Raised when the stp solver cannot produce a solution for the problem | ||
""" | ||
Exception.__init__(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,61 @@ | ||
from stn.utils.uuid import generate_uuid | ||
from stn.utils.uuid import from_str | ||
|
||
|
||
class Node(object): | ||
"""Represents a timepoint in the STN """ | ||
|
||
def __init__(self, task_id, pose, node_type): | ||
def __init__(self, task_id, node_type, is_executed=False, **kwargs): | ||
# id of the task represented by this node | ||
if isinstance(task_id, str): | ||
task_id = from_str(task_id) | ||
self.task_id = task_id | ||
# Pose in the map where the node has to be executed | ||
self.pose = pose | ||
# The node can be of node_type zero_timepoint, navigation, start or finish | ||
# The node can be of node_type zero_timepoint, start, pickup or delivery | ||
self.node_type = node_type | ||
self.is_executed = is_executed | ||
self.action_id = kwargs.get("action_id") | ||
|
||
def __str__(self): | ||
to_print = "" | ||
to_print += "node {} {}".format(self.task_id, self.node_type) | ||
to_print += "{} {} ".format(self.task_id, self.node_type) | ||
return to_print | ||
|
||
def __repr__(self): | ||
return str(self.to_dict()) | ||
|
||
def __hash__(self): | ||
return hash((self.task_id, self.pose, self.node_type)) | ||
return hash((self.task_id, self.node_type, self.is_executed)) | ||
|
||
def __eq__(self, other): | ||
if other is None: | ||
return False | ||
return (self.task_id == other.task_id and | ||
self.pose == other.pose and | ||
self.node_type == other.node_type) | ||
self.node_type == other.node_type and | ||
self.is_executed == other.is_executed and | ||
self.action_id == other.action_id) | ||
|
||
def __ne__(self, other): | ||
return not self.__eq__(other) | ||
|
||
def execute(self): | ||
self.is_executed = True | ||
|
||
def to_dict(self): | ||
node_dict = dict() | ||
node_dict['task_id'] = self.task_id | ||
node_dict['pose'] = self.pose | ||
node_dict['task_id'] = str(self.task_id) | ||
node_dict['node_type'] = self.node_type | ||
node_dict['is_executed'] = self.is_executed | ||
if self.action_id: | ||
node_dict['action_id'] = str(self.action_id) | ||
return node_dict | ||
|
||
@staticmethod | ||
def from_dict(node_dict): | ||
task_id = node_dict['task_id'] | ||
pose = node_dict['pose'] | ||
if isinstance(task_id, str): | ||
task_id = from_str(task_id) | ||
node_type = node_dict['node_type'] | ||
node = Node(task_id, pose, node_type) | ||
is_executed = node_dict.get('is_executed', False) | ||
node = Node(task_id, node_type, is_executed) | ||
if node_dict.get('action_id'): | ||
node.action_id = from_str(node_dict['action_id']) | ||
return node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.