Skip to content

Commit

Permalink
documented
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulgoel873 committed May 15, 2024
1 parent afc02f4 commit 9c78a2b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions rb_ws/src/buggy/scripts/util/rosbag_to_pose_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import rosbag
from tf.transformations import euler_from_quaternion


def main():
"""
bag_file is an input that reads the path to the bag file
output_file is an argument that reads the path to the output file
subsample is the number of points to be selected to be converted to waypoints
"""
# Read in bag path from command line
parser = argparse.ArgumentParser()
parser.add_argument("bag_file", help="Path to bag file")
Expand Down Expand Up @@ -36,16 +42,21 @@ def main():
lon = msg.pose.pose.position.y
orientation_q = msg.pose.pose.orientation

orientation_list = [orientation_q.x, orientation_q.y, orientation_q.z, orientation_q.w]
(_, _, yaw) = euler_from_quaternion (orientation_list)

orientation_list = [
orientation_q.x,
orientation_q.y,
orientation_q.z,
orientation_q.w,
]
(_, _, yaw) = euler_from_quaternion(orientation_list)

waypoints.append([str(lat), str(lon), str(yaw)])

# Write to csv file
with open(args.output_file, 'w', newline='') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
with open(args.output_file, "w", newline="") as csvfile:
writer = csv.writer(
csvfile, delimiter=",", quotechar="|", quoting=csv.QUOTE_MINIMAL
)
for row in waypoints:
writer.writerow(row)

Expand Down

0 comments on commit 9c78a2b

Please sign in to comment.