-
Notifications
You must be signed in to change notification settings - Fork 2
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 #40 from maxspahn/ft-point-fk
ft[pointfk]: restores point fk and aligns planar fks with common fk.
- Loading branch information
Showing
7 changed files
with
187 additions
and
19 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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from typing import Union | ||
|
||
import numpy as np | ||
import casadi as ca | ||
|
||
from forwardkinematics.planarFks.planar_fk import ForwardKinematicsPlanar | ||
|
||
|
||
class PointFk(ForwardKinematicsPlanar): | ||
def __init__(self): | ||
super().__init__() | ||
self._n = 2 | ||
|
||
def casadi( | ||
self, | ||
q: ca.SX, | ||
child_link: Union[int, str], | ||
parent_link: Union[int, str, None] = None, | ||
link_transformation=np.eye(3), | ||
position_only: bool = False, | ||
): | ||
fk = ca.SX.eye(3) | ||
child_link = self.ensure_int_link(child_link) | ||
if not parent_link: | ||
parent_link = 0 | ||
parent_link = self.ensure_int_link(parent_link) | ||
if not parent_link: | ||
parent_link = 0 | ||
if parent_link == 0 and child_link > 0: | ||
fk[0:2, 2] = q | ||
fk = ca.mtimes(fk, link_transformation) | ||
if position_only: | ||
return fk[0:2, 2] | ||
else: | ||
return fk | ||
|
||
def numpy( | ||
self, | ||
q: np.ndarray, | ||
child_link: Union[int, str], | ||
parent_link: Union[int, str, None] = None, | ||
link_transformation=np.eye(3), | ||
position_only: bool = False, | ||
): | ||
fk = np.eye(3) | ||
child_link = self.ensure_int_link(child_link) | ||
if not parent_link: | ||
parent_link = 0 | ||
parent_link = self.ensure_int_link(parent_link) | ||
if not parent_link: | ||
parent_link = 0 | ||
if parent_link == 0 and child_link > 0: | ||
fk[0:2, 2] = q | ||
fk = np.dot(fk, link_transformation) | ||
if position_only: | ||
return fk[0:2, 2] | ||
else: | ||
return fk |
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,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "forwardkinematics" | ||
version = "1.2.1" | ||
version = "1.2.2" | ||
description = "\"Light-weight implementation of forward kinematics using casadi.\"" | ||
authors = ["Max Spahn <[email protected]>"] | ||
license = "MIT" | ||
|
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,28 @@ | ||
import pytest | ||
import casadi as ca | ||
import numpy as np | ||
|
||
from forwardkinematics.fksCommon.fk import ForwardKinematics | ||
from forwardkinematics.planarFks.planar_fk import ForwardKinematicsPlanar | ||
|
||
class myFK(ForwardKinematics): | ||
pass | ||
|
||
class myPlanarFK(ForwardKinematicsPlanar): | ||
pass | ||
|
||
|
||
def test_myFK(): | ||
fk = myFK() | ||
with pytest.raises(NotImplementedError): | ||
fk.casadi(ca.SX.sym('q', 6), 3) | ||
with pytest.raises(NotImplementedError): | ||
fk.numpy(np.ones(5), 5) | ||
|
||
def test_myPlanarFk(): | ||
fk = myPlanarFK() | ||
with pytest.raises(NotImplementedError): | ||
fk.casadi(ca.SX.sym('q', 6), 3) | ||
with pytest.raises(NotImplementedError): | ||
fk.numpy(np.ones(5), 5) | ||
|
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