43 LIBAMINOMP = ctypes.CDLL(
"libamino-planning.so")
45 class RxMp(ctypes.Structure):
46 """Opaque type for struct aa_rx_mp"""
49 """Context object for motion planning."""
53 def __init__(self, ssg):
54 self.
_ptr_ptr = LIBAMINOMP.aa_rx_mp_create(ssg._ptr)
58 LIBAMINOMP.aa_rx_mp_destroy(self.
_ptr_ptr)
62 """Compute a motion plan.
65 start: A list containing the current configuration space state
66 goal: A list containing the goal configuraiton space state
67 timeout: Timout before a motion planning failure is declared
70 None if no motion plan is found, a list of configurations (the
71 motion plan) otherwise.
74 c_start = (ctypes.c_double * len(start))(*start)
75 c_goal = (ctypes.c_double * len(goal))(*goal)
76 LIBAMINOMP.aa_rx_mp_set_start(self.
_ptr_ptr, len(start), c_start)
77 if LIBAMINOMP.aa_rx_mp_set_goal(self.
_ptr_ptr, len(goal), c_goal) != AA_RX_OK:
80 LIBAMINOMP.aa_rx_mp_set_simplify(self.
_ptr_ptr, ctypes.c_int(1))
82 n_path = ctypes.c_size_t(0)
84 path = ctypes.POINTER(ctypes.c_double)()
85 ret = LIBAMINOMP.aa_rx_mp_plan(self.
_ptr_ptr, timeout, ctypes.byref(n_path),
92 for i
in range(0, n_path.value*len(start), len(start)):
94 for j
in range(0, len(start)):
95 cord.append(path[i+j])
101 LIBAMINOMP.aa_rx_mp_create.argtypes = [ctypes.POINTER(RxSgSub)]
102 LIBAMINOMP.aa_rx_mp_create.restype = ctypes.POINTER(RxMp)
104 LIBAMINOMP.aa_rx_mp_destroy.argtypes = [ctypes.POINTER(RxMp)]
106 LIBAMINOMP.aa_rx_mp_set_simplify.argtypes = [ctypes.POINTER(RxMp), ctypes.c_int]
107 LIBAMINOMP.aa_rx_mp_set_sbl.argtypes = [ctypes.POINTER(RxMp), ctypes.POINTER(ctypes.c_int)]
109 LIBAMINOMP.aa_rx_mp_set_start.argtypes = [ctypes.POINTER(RxMp), ctypes.c_int,
110 ctypes.POINTER(ctypes.c_double)]
112 LIBAMINOMP.aa_rx_mp_set_goal.argtypes = [ctypes.POINTER(RxMp), ctypes.c_int,
113 ctypes.POINTER(ctypes.c_double)]
115 LIBAMINOMP.aa_rx_mp_plan.argtypes = [ctypes.POINTER(RxMp), ctypes.c_double,
116 ctypes.POINTER(ctypes.c_size_t),
117 ctypes.POINTER(ctypes.POINTER(ctypes.c_double))]
def motion_plan(self, start, goal, timeout)
Compute a motion plan.