
[英]typeerror unsupported operand type(s) for / 'str' and 'int'
[英]"unsupported operand type(s) for *: 'int' and 'GreaterThan'" issure
我有这个问题:
TypeError Traceback (most recent call last)
<ipython-input-88-03e362e106e6> in <module>
12 g : 9.81,
13 l : 2.0,
---> 14 f: force(t)}
15
16 # Create a function from the equations of motion
<ipython-input-86-565059232bb5> in force(t)
6
7 # return a bang-bang command
----> 8 return fmax * ((t > 0.25) - 2 * (t >= 1.25) + (t >= 2.25))
TypeError: unsupported operand type(s) for *: 'int' and 'GreaterThan'"
我试图解决它,但我不能。 有人能帮我吗?
从此代码:
def force(t):
# set the maximum force output
fmax = 10
# return a bang-bang command
return fmax * ((t > 0.25) - 2 * (t >= 1.25) + (t >= 2.25))
# Define the states and state vector
w1, w2, w3, w4 = sympy.symbols('w1 w2 w3 w4', cls=sympy.Function)
w = [w1(t), w2(t), w3(t), w4(t)]
# Set up the state definitions and parameter substitution
sub_params = {x : w1(t),
theta : w2(t),
x_dot : w3(t),
theta_dot : w4(t),
mt : 10.0,
m : 1.0,
g : 9.81,
l : 2.0,
f: force(t)}
# Create a function from the equations of motion
# Here, we substitude the states and parameters as appropriate prior to the lamdification
eq_of_motion = sympy.lambdify((t, w), lrhs.subs(sub_params))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.