Skip to content

Commit

Permalink
use ndarray.tolist to convert numpy array to float (commaai#23485)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee authored Jan 11, 2022
1 parent 44592f4 commit 35ec6ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions selfdrive/controls/lib/lateral_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ def publish(self, sm, pm):

lateralPlan = plan_send.lateralPlan
lateralPlan.laneWidth = float(self.LP.lane_width)
lateralPlan.dPathPoints = [float(x) for x in self.y_pts]
lateralPlan.psis = [float(x) for x in self.lat_mpc.x_sol[0:CONTROL_N, 2]]
lateralPlan.curvatures = [float(x) for x in self.lat_mpc.x_sol[0:CONTROL_N, 3]]
lateralPlan.dPathPoints = self.y_pts.tolist()
lateralPlan.psis = self.lat_mpc.x_sol[0:CONTROL_N, 2].tolist()
lateralPlan.curvatures = self.lat_mpc.x_sol[0:CONTROL_N, 3].tolist()
lateralPlan.curvatureRates = [float(x) for x in self.lat_mpc.u_sol[0:CONTROL_N - 1]] + [0.0]
lateralPlan.lProb = float(self.LP.lll_prob)
lateralPlan.rProb = float(self.LP.rll_prob)
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/controls/lib/longitudinal_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def publish(self, sm, pm):
longitudinalPlan.modelMonoTime = sm.logMonoTime['modelV2']
longitudinalPlan.processingDelay = (plan_send.logMonoTime / 1e9) - sm.logMonoTime['modelV2']

longitudinalPlan.speeds = [float(x) for x in self.v_desired_trajectory]
longitudinalPlan.accels = [float(x) for x in self.a_desired_trajectory]
longitudinalPlan.jerks = [float(x) for x in self.j_desired_trajectory]
longitudinalPlan.speeds = self.v_desired_trajectory.tolist()
longitudinalPlan.accels = self.a_desired_trajectory.tolist()
longitudinalPlan.jerks = self.j_desired_trajectory.tolist()

longitudinalPlan.hasLead = sm['radarState'].leadOne.status
longitudinalPlan.longitudinalPlanSource = self.mpc.source
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/locationd/calibrationd.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ def get_msg(self):
msg.liveCalibration.validBlocks = self.valid_blocks
msg.liveCalibration.calStatus = self.cal_status
msg.liveCalibration.calPerc = min(100 * (self.valid_blocks * BLOCK_SIZE + self.idx) // (INPUTS_NEEDED * BLOCK_SIZE), 100)
msg.liveCalibration.extrinsicMatrix = [float(x) for x in extrinsic_matrix.flatten()]
msg.liveCalibration.rpyCalib = [float(x) for x in smooth_rpy]
msg.liveCalibration.rpyCalibSpread = [float(x) for x in self.calib_spread]
msg.liveCalibration.extrinsicMatrix = extrinsic_matrix.flatten().tolist()
msg.liveCalibration.rpyCalib = smooth_rpy.tolist()
msg.liveCalibration.rpyCalibSpread = self.calib_spread.tolist()
return msg

def send_data(self, pm) -> None:
Expand Down

0 comments on commit 35ec6ac

Please sign in to comment.