Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing the navigation when using kmall_to_ros_bag.py #18

Open
Kurtaja opened this issue Dec 19, 2023 · 1 comment
Open

Missing the navigation when using kmall_to_ros_bag.py #18

Kurtaja opened this issue Dec 19, 2023 · 1 comment

Comments

@Kurtaja
Copy link

Kurtaja commented Dec 19, 2023

Hi, I'm trying to use the kmall_to_ros_bag.py script with the aim to obtain a point cloud file from it. This is how I call the script
'python kmall_to_ros_bag.py -o myBagFile.bag myKmFile.kmall'
, which creates the 'myBagFile.bag' file ok. Then I convert it to a pcd file with this script,
"
import rosbag
import sensor_msgs.point_cloud2 as pc2
import numpy as np
import open3d as o3d

def bag_to_pcd(bag_file, topic, output_pcd_file):
accumulated_points = []

with rosbag.Bag(bag_file, 'r') as bag:
    for _, msg, _ in bag.read_messages(topics=[topic]):
        pc_data = pc2.read_points(msg, field_names=("x", "y", "z"), skip_nans=True)
        pc_np = np.array(list(pc_data))
        pc_xyz = pc_np[:, :3]
        accumulated_points.append(pc_xyz)

# Concatenate all points
if accumulated_points:
    all_points = np.concatenate(accumulated_points, axis=0)
    point_cloud = o3d.geometry.PointCloud()
    point_cloud.points = o3d.utility.Vector3dVector(all_points)
    o3d.io.write_point_cloud(output_pcd_file, point_cloud)

if name == "main":
bag_file = "myBagFile.bag"
topic = "mbes/pings"
output_pcd_file = "myPclFile.pcd"

bag_to_pcd(bag_file, topic, output_pcd_file)

"
, which also makes the 'myPclFile.pcd' file ok. However, when displaying the pcd file in a point cloud viewer, all the scans end up in the same spot, as if the vessel was not moving (which it is). I'm sure there must be a dead simple detail that I'm missing, but I'm not able to figure how. Do you have the possibility to show me how I can make sure that I get the navigation, attitudes as well as compensation for svp into the exported files?
Kind regards

@rolker
Copy link
Contributor

rolker commented Dec 19, 2023

As is, the kmall_to_ros_bag.py file does not save the navigation in the ROS bag file. For my use case, I already had the navigation available in another ROS bag file so I only needed properly timestamped PointCloud messages.

The script could be extended to also save the nav data. We'd need to think a bit about the best ROS message(s) to use for the nav data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants