Reputation: 1
here is the problem:
constants: enter image description here
dependent value functions:
def v_ego(self,ego_vel_x,ego_a_ini_x,t):
v_ego = ego_vel_x + ego_a_ini_x * t
return v_ego
def x_obj(self,x_obj_ini,obj_vel_x,obj_a_ini_x,t):
x_obj = x_obj_ini + obj_vel_x * t + 0.5 * obj_a_ini_x * t ** 2
return x_obj
def x_ego(self,x_ego_ini,ego_vel_x,ego_a_ini_x,t):
x_ego = x_ego_ini + ego_vel_x * t + 0.5 * ego_a_ini_x * t ** 2
return x_ego
def y_obj(self,y_obj_ini,obj_vel_y,obj_a_ini_y,t):
y_obj = y_obj_ini + obj_vel_y * t + 0.5 * obj_a_ini_y * t ** 2
return y_obj
def y_t(self):
y_t = math.sqrt(self._r_t ** 2 - self._l_f ** 2) - (self._w_ego / 2)
return y_t
def y_r(self,ego_vel_x,ego_a_ini_x,t):
y_r = math.sqrt(max(0, ((self.v_ego(ego_vel_x,ego_a_ini_x,t) ** 2 / (self
._Mu_rt * self._g)) ** 2 - self._l_c ** 2)))
return y_r
def y_min(self,ego_vel_x,ego_a_ini_x,t):
y_min = max(self.y_t(), self.y_r(ego_vel_x,ego_a_ini_x,t))
return y_min
def r_min(self,ego_vel_x,ego_a_ini_x,t):
r_min = max(self._r_t, math.sqrt(self._l_f ** 2 + (self.y_min(ego_vel_x,ego_a_ini_x,t) + self._w_ego / 2) ** 2))
return r_min
tts, delta_t = sym.symbols('tts,delta_t')
e_10 = sym.Eq(math.atan((self.x_obj(x_obj_ini, obj_vel_x, obj_a_ini_x, tts + delta_t) - self.x_ego(x_ego_ini,ego_vel_x,ego_a_ini_x,tts)+ self._l_f) / (self.y_min(ego_vel_x, ego_a_ini_x, tts) - self.y_obj(y_obj_ini, obj_vel_y, obj_a_ini_y,tts + delta_t))) - ((self.v_ego(ego_vel_x, ego_a_ini_x, tts) * delta_t) / self.r_min(ego_vel_x, ego_a_ini_x, tts) - (math.asin(min(1.0, self._l_f / self.r_min(ego_vel_x, ego_a_ini_x, tts))))), 0)
e_11 = sym.Eq((self.x_obj(x_obj_ini, obj_vel_x, obj_a_ini_x, tts + delta_t) - self.x_ego(x_ego_ini, ego_vel_x,ego_a_ini_x,tts)+ self._l_f) ** 2 + (self.y_min(ego_vel_x, ego_a_ini_x, tts) - self.y_obj(y_obj_ini, obj_vel_y, obj_a_ini_y,tts + delta_t)) ** 2 - (self.r_min(ego_vel_x, ego_a_ini_x, tts)) ** 2, 0)
print(sym.solve([e_10, e_11], (tts, delta_t)))
I am getting TypeError: cannot determine truth value of Relational
These are the equations: non linear equations that I am trying to solve
and these are the dependent values that need to be calculated:
any help is appreciated
Upvotes: 0
Views: 47
Reputation: 19135
When you use min with a SymPy expressions, it will complain if it can't figure out what the min is, e.g. min(x,y) -> TypeError: cannot determine truth value of Relational
.
Since you are only selecting a minimum of two values, the function is easy to write as a Piecewise as in the following example where the equation x - min(y,z)
is being solved.
Replace max
with a similar rewrite, too.
Upvotes: 0