Skip to content

Commit 68ffcdb

Browse files
committed
Correctly recognise static ET with symbolic values
1 parent 53c6b19 commit 68ffcdb

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

roboticstoolbox/core/fknm.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,9 @@ extern "C"
11241124

11251125
et = (ET *)PyMem_RawMalloc(sizeof(ET));
11261126

1127-
if (!PyArg_ParseTuple(args, "OiiiiO!O!",
1127+
if (!PyArg_ParseTuple(args, "OiiiiiO!O!",
11281128
&py_et,
1129+
&et->isstaticsym,
11291130
&isjoint,
11301131
&isflip,
11311132
&jindex,
@@ -1188,7 +1189,8 @@ extern "C"
11881189

11891190
et = (ET *)PyMem_RawMalloc(sizeof(ET));
11901191

1191-
if (!PyArg_ParseTuple(args, "iiiiO!O!",
1192+
if (!PyArg_ParseTuple(args, "iiiiiO!O!",
1193+
&et->isstaticsym,
11921194
&et->isjoint,
11931195
&et->isflip,
11941196
&et->jindex,
@@ -1252,6 +1254,12 @@ extern "C"
12521254
if (!(et = (ET *)PyCapsule_GetPointer(py_et, "ET")))
12531255
return NULL;
12541256

1257+
if (et->isstaticsym)
1258+
{
1259+
PyErr_SetString(PyExc_TypeError, "Symbolic value");
1260+
return NULL;
1261+
}
1262+
12551263
if (py_eta != Py_None)
12561264
{
12571265
if (PyFloat_Check(py_eta))

roboticstoolbox/core/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern "C"
4040

4141
struct ET
4242
{
43+
int isstaticsym; /* this ET is static and has a symbolic value */
4344
int isjoint;
4445
int isflip;
4546
int jindex;

roboticstoolbox/robot/ET.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def __init__(
4646
):
4747
self._axis = axis
4848

49+
# A flag to check if the ET is a static joint with a symbolic value
50+
# Defaults to False as is set to True if eta is a symbol below
51+
self._isstaticsym = False
52+
4953
if eta is None:
5054
self._eta = None
5155
else:
@@ -74,6 +78,10 @@ def __init__(
7478
self._joint = False
7579
self._T = T.copy(order="F")
7680
else:
81+
# This is a static joint
82+
if issymbol(eta):
83+
self._isstaticsym = True
84+
7785
self._joint = False
7886
if axis_func is not None:
7987
self._T = axis_func(self.eta).copy(order="F")
@@ -102,6 +110,7 @@ def __init_c(self):
102110
qlim = self.qlim
103111

104112
return ET_init(
113+
self._isstaticsym,
105114
self.isjoint,
106115
self.isflip,
107116
jindex,
@@ -126,6 +135,7 @@ def __update_c(self):
126135

127136
ET_update(
128137
self.fknm,
138+
self._isstaticsym,
129139
self.isjoint,
130140
self.isflip,
131141
jindex,
@@ -135,7 +145,6 @@ def __update_c(self):
135145
)
136146

137147
def __str__(self):
138-
139148
eta_str = ""
140149

141150
if self.isjoint:
@@ -175,7 +184,6 @@ def __str__(self):
175184
return f"{self.axis}({eta_str})"
176185

177186
def __repr__(self):
178-
179187
s_eta = "" if self.eta is None else f"eta={self.eta}"
180188
s_T = (
181189
f"T={repr(self._T)}"
@@ -553,7 +561,7 @@ def A(self, q: Union[float, Sym] = 0.0) -> ndarray:
553561
# We can't use the fast version, lets use Python instead
554562
if self.isjoint:
555563
if self.isflip:
556-
q = -1.0 * q
564+
q = -q
557565

558566
if self.axis_func is not None:
559567
return self.axis_func(q)

0 commit comments

Comments
 (0)