Skip to content

Commit

Permalink
Reformatted code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewHWang1605 committed Apr 25, 2024
1 parent df43315 commit 32b6504
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 96 deletions.
4 changes: 2 additions & 2 deletions ff_sim/ff_sim/controller_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def process_new_binary_thrust_cmd(self, msg: ThrusterCommand) -> None:
self.prev_thruster_sum = np.sum(thrusters)

self.steps += 1
if not self.rolled_up: # Ensure valid duty cycles at the beginning
if not self.rolled_up: # Ensure valid duty cycles at the beginning
self.time_hist.append(dt)
for i in range(8):
self.thrust_hist[i].append(thrusters[i])
Expand All @@ -99,7 +99,7 @@ def process_new_binary_thrust_cmd(self, msg: ThrusterCommand) -> None:
)
if self.steps >= self.duty_cycle_window:
self.rolled_up = True
else: # Once queue is filled up, can just treat this as a list that's constantly being updawted
else: # Once queue is filled up, can just treat this as a list that's constantly being updawted
self.time_hist.pop(0)
self.time_hist.append(dt)
for i in range(8):
Expand Down
4 changes: 2 additions & 2 deletions ff_sim/ff_sim/simulator_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ def compute_dynamics_dt(self, x_k, u_k, dt, discretization="Euler"):
print("[FreeFlyerSimulator::compute_dynamics_dt]: Unknown Discretization Scheme.")

# Wrap theta to [-pi, pi]

# x_next[2] = ((x_next[2] % (2 * np.pi)) + 2 * np.pi) % (2 * np.pi)
# if x_next[2] > np.pi:
# x_next[2] -= 2 * np.pi
x_next[2] = (x_next[2] + np.pi) % (2*np.pi) - np.pi
x_next[2] = (x_next[2] + np.pi) % (2 * np.pi) - np.pi

return x_next

Expand Down
15 changes: 11 additions & 4 deletions testing_files/injectGoalPose.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@
import math
import sys

goal_positions = [[0.5,0.5,-math.pi/2], [0.5,0.5,math.pi/2], [1.0,1.0,math.pi/2], [2.0,1.5,math.pi/2]]
goal_velos = [[0.0,0.0,0.0], [0.0,0.0,0.0], [0.0,0.0,0.0], [0.0,0.0,0.0]]
goal_positions = [
[0.5, 0.5, -math.pi / 2],
[0.5, 0.5, math.pi / 2],
[1.0, 1.0, math.pi / 2],
[2.0, 1.5, math.pi / 2],
]
goal_velos = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]


class GoalPublisherNode(Node):
def __init__(self, index):
Expand All @@ -54,10 +60,11 @@ def publish_goal(self, pos, velo):
goal_pose.state.pose.theta = pos[2]
goal_pose.state.twist.vx = velo[0]
goal_pose.state.twist.vy = velo[1]
goal_pose.state.twist.wz = velo[2]
goal_pose.state.twist.wz = velo[2]

self.pub_goal.publish(goal_pose)


def main():
index = int(sys.argv[1])
rclpy.init()
Expand All @@ -66,6 +73,6 @@ def main():
rclpy.spin(publisher)
rclpy.shutdown()


if __name__ == "__main__":
main()

Loading

0 comments on commit 32b6504

Please sign in to comment.