Beispiel #1
0
import rdml_graph as gr
import numpy as np
import matplotlib.pyplot as plt
import numpy as np

import time

############### Create PRM
map = {
    'width': 20,
    'height': 20,
    'hazards': np.array([[5.0, 5.0], [7.5, 3.0]])
}

startN = gr.GeometricNode(0, np.array([6, 7]))
endN = gr.GeometricNode(1, np.array([8.5, 7]))

G = gr.PRM(map, 100, 6.0, connection=gr.HEdgeConn, initialNodes=[startN, endN])

############### Setup and run AStar
num_features = map['hazards'].shape[0]
# Create the start homotopy node over the PRM graph.
start = gr.HNode(G[0], gr.HomologySignature(num_features), root=G[0])

# Create the goal h signature.
goalPartialHSign = gr.HomologySignatureGoal(num_features)
goalPartialHSign.addConstraint(0, -1)  # add constraints to goal hsign
goalPartialHSign.addConstraint(1, 0)

start_t = time.time()
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

# TestHomotopySignature.py
# Written Ian Rankin - October 2020
#
# A test function for the homotopy signature class.

import rdml_graph as gr
import numpy as np

n = gr.GeometricNode(0,np.array([-1,1]))
n1 = gr.GeometricNode(1, np.array([1,2]))
n2 = gr.GeometricNode(2, np.array([3,4]))
n3 = gr.GeometricNode(3, np.array([4.4,-3]))
n4 = gr.GeometricNode(4, np.array([-2.2,-10]))
n5 = gr.GeometricNode(5, np.array([0,3.2]))


sign = gr.HomotopySignature([])
sign.cross(1, 1)
print(sign)
sign.cross(2,1)
print(sign)
sign.cross(2,-1)
print(sign)
sign.cross(2,-1)
Beispiel #3
0
# DEALINGS IN THE SOFTWARE.
#
# SaveAndLoadGraph.py
# Written Ian Rankin - March 2020
#
# An example set of code to show loading and saving a graph structure using pickle

import rdml_graph as gr
import numpy as np
import matplotlib.pyplot as plt

import pickle

features = np.array([[0, 0]])

n = gr.GeometricNode(0, np.array([-3, -3]))
n1 = gr.GeometricNode(1, np.array([-3.3, 3]))
n2 = gr.GeometricNode(2, np.array([3.4, -2]))
n3 = gr.GeometricNode(3, np.array([4.4, -3]))
n4 = gr.GeometricNode(4, np.array([-2.2, -10]))
n5 = gr.GeometricNode(5, np.array([4.5, 3.2]))

G = [n, n1, n2, n3, n4, n5]

sign = gr.HomologySignature(features.shape[0])
n.addEdge(gr.HEdge(n, n1, sign, features=features))
n1.addEdge(gr.HEdge(n1, n, sign, features=features))

n.addEdge(gr.HEdge(n, n2, sign, features=features))
n2.addEdge(gr.HEdge(n2, n, sign, features=features))