Skip to content

LocalizationNode - #1

Open
ar961na wants to merge 10 commits into
mainfrom
test
Open

LocalizationNode#1
ar961na wants to merge 10 commits into
mainfrom
test

Conversation

@ar961na

@ar961na ar961na commented May 19, 2026

Copy link
Copy Markdown
Owner

No description provided.

Comment thread docker/Dockerfile
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F42ED6FBAB17C654

# Install livox_ros_driver2 for Livox LiDAR support
RUN apt-get update && apt-get install -y git build-essential \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавь после установки зависимостей rm -rf /var/lib/apt/lists/*

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/requirements-docker.txt Outdated

numpy==1.23.5
scipy==1.9.3
scikit-learn>=0.23.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стоит указать точную версию

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/global_align.py Outdated
Comment on lines +37 to +38
self.ransac_max_iterations = 1_000_000 # Reduced for 30% speedup
self.ransac_confidence = 200 # Reduced for early stopping

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Немного запутывает название self.ransac_confidence, confidence это больше про вероятность. Тут судя по документации более уместно max_validation. Также лучше вынести эти параметры в конструктор класса.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/global_align.py Outdated
"""Return current RANSAC parameters."""
return {
"max_iterations": self.ransac_max_iterations,
"confidence": self.ransac_confidence,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поменяй слово confidence здесь

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/common.py Outdated
Returns:
Transformed trajectory with same format.
"""
from scipy.spatial.transform import Rotation

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше располагать все импорты в начале файла согласно PEP 8

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread requirements.txt Outdated
@@ -0,0 +1 @@
pyyaml No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно указать конкретную версию пакета

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/Dockerfile
RUN apt-get update && apt-get install -y git build-essential \
&& mkdir -p /home/mars_ugv/livox_ws/src \
&& cd /home/mars_ugv/livox_ws/src \
&& git clone https://github.com/Livox-SDK/livox_ros_driver2.git \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь лучше зафиксировать конкретный коммит

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/Dockerfile Outdated

# Copy application code
COPY nodes/ /opt/fastlio_localization/nodes/
#COPY docker/pipeline_all_in_docker.py /opt/fastlio_localization/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Забыла убрать

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/Dockerfile Outdated
COPY config/ /opt/fastlio_localization/config/
COPY scripts/downsample_reference.py /opt/fastlio_localization/scripts/downsample_reference.py

RUN chmod +x /opt/fastlio_localization/scripts/downsample_reference.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно сделать любые файлы исполняемыми у себя локально и закоммитить. Тогда после git clone репозитория файлы сразу будут исполняемыми и вот так делать не придется

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/common.py Outdated
Comment on lines +131 to +143
if ext == ".pcd":
return PointCloudProcessor.load_pcd(filepath)
elif ext == ".obj":
mesh = o3d.io.read_triangle_mesh(filepath)
pcd = mesh.sample_points_uniformly(number_of_points=int(1e6))
if len(pcd.points) == 0:
raise ValueError(f"Empty mesh/point cloud: {filepath}")
return pcd
elif ext == ".ply":
pcd = o3d.io.read_point_cloud(filepath)
if len(pcd.points) == 0:
raise ValueError(f"Empty point cloud: {filepath}")
return pcd

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну как будто pcd и ply по итогу одинаково загружаются

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merged

Comment thread nodes/common.py Outdated
Comment on lines +257 to +264
point = np.array([x, y, z])
transformed_point = transform_point(point, T)

quat = np.array([qx, qy, qz, qw])
R_odom = Rotation.from_quat(quat).as_matrix()
R_ref = T[:3, :3] @ R_odom
R_rot = Rotation.from_matrix(R_ref)
quat_transformed = R_rot.as_quat()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно просто сразу сделать матрицу 4х4 и умножить её на T, тогда за одно умножение получится то же самое

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/localization_node.py Outdated
self.trajectory_buffer.append([stamp, x, y, z, qx, qy, qz, qw])

# Limit buffer size
if len(self.trajectory_buffer) > 10000:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше вынести константу куда-нибудь в инициализацию класса

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/localization_node.py Outdated
Comment on lines +338 to +345
# Transform position
pos_h = np.append(pos, 1.0)
pos_ref = (T @ pos_h)[:3]

# Transform orientation
R_odom = Rotation.from_quat(quat).as_matrix()
R_ref = T[:3, :3] @ R_odom
quat_ref = Rotation.from_matrix(R_ref).as_quat()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь тот же самый момент, можно обойтись одним умножением

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread scripts/create_gif.py Outdated
from PIL import Image


def load_point_cloud(filepath: str) -> o3d.geometry.PointCloud:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется уже где-то это было

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, точно такая же функция используется в nodes/common.py PointCloudProcessor.

В унифицированном скрипте scripts/visualize.py я оставила копию функции загрузки облака, чтобы его можно было использовать отдельно от узла локализации.

Comment thread scripts/visualize_trajectory.py Outdated
return geometries


def _save_visualization_as_gif(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень похоже на то, что происходит в create_gif.py, может можно унифицировать?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

объединила функционал create_gif.py и visualize_trajectory.py в один файл visualize.py

ar961na added 4 commits June 8, 2026 13:51
- Add PointCloudProcessor.load_downsampled() for memoized static clouds;
- Update Global and LocalAlign to use pre-processed clouds and cached targets;
- Implement LocalAlign._select_seed() for warm-starting with candidate seeds (previous + fresh global);
- Add buffer_lock for thread-safe concurrent access;
- Switch to deque with automatic pruning.
- Update README.md, config/pipeline_config.yaml  and .gitignore;
- Simplify docker/docker_build_and_run.sh print_header function;
- Simplify scripts/visualize.py logic.

@ar961na ar961na left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Спасибо, исправила комментарии

Comment thread docker/Dockerfile
RUN apt-get update && apt-get install -y git build-essential \
&& mkdir -p /home/mars_ugv/livox_ws/src \
&& cd /home/mars_ugv/livox_ws/src \
&& git clone https://github.com/Livox-SDK/livox_ros_driver2.git \

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/Dockerfile
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F42ED6FBAB17C654

# Install livox_ros_driver2 for Livox LiDAR support
RUN apt-get update && apt-get install -y git build-essential \

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/Dockerfile Outdated

# Copy application code
COPY nodes/ /opt/fastlio_localization/nodes/
#COPY docker/pipeline_all_in_docker.py /opt/fastlio_localization/

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/Dockerfile Outdated
COPY config/ /opt/fastlio_localization/config/
COPY scripts/downsample_reference.py /opt/fastlio_localization/scripts/downsample_reference.py

RUN chmod +x /opt/fastlio_localization/scripts/downsample_reference.py

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread docker/requirements-docker.txt Outdated

numpy==1.23.5
scipy==1.9.3
scikit-learn>=0.23.0

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread scripts/visualize_trajectory.py Outdated
return geometries


def _save_visualization_as_gif(

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

объединила функционал create_gif.py и visualize_trajectory.py в один файл visualize.py

Comment thread scripts/create_gif.py Outdated
from PIL import Image


def load_point_cloud(filepath: str) -> o3d.geometry.PointCloud:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, точно такая же функция используется в nodes/common.py PointCloudProcessor.

В унифицированном скрипте scripts/visualize.py я оставила копию функции загрузки облака, чтобы его можно было использовать отдельно от узла локализации.

Comment thread nodes/common.py Outdated
Comment on lines +257 to +264
point = np.array([x, y, z])
transformed_point = transform_point(point, T)

quat = np.array([qx, qy, qz, qw])
R_odom = Rotation.from_quat(quat).as_matrix()
R_ref = T[:3, :3] @ R_odom
R_rot = Rotation.from_matrix(R_ref)
quat_transformed = R_rot.as_quat()

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/localization_node.py Outdated
Comment on lines +338 to +345
# Transform position
pos_h = np.append(pos, 1.0)
pos_ref = (T @ pos_h)[:3]

# Transform orientation
R_odom = Rotation.from_quat(quat).as_matrix()
R_ref = T[:3, :3] @ R_odom
quat_ref = Rotation.from_matrix(R_ref).as_quat()

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nodes/localization_node.py Outdated
self.trajectory_buffer.append([stamp, x, y, z, qx, qy, qz, qw])

# Limit buffer size
if len(self.trajectory_buffer) > 10000:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ar961na
ar961na requested review from rongirl and vnmsklnk June 9, 2026 10:27
ar961na added 5 commits June 10, 2026 17:44
- Add optional initial_pose parameter to config and pipeline for complex cases;
- Add rebase rotation/translation thresholds for detecting basin switches;- Save both trajectory_reference.txt (rebased) and trajectory_reference_raw.txt (published) odometries;
- Add config and it's parameters (e.g. duration, align_interval, map_accumulation_time) v
alidation in docker build script;
- Fix issue with leftover tail being not localized.
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

Successfully merging this pull request may close these issues.

3 participants