Skip to content

Commit b73ff8b

Browse files
refactoring
1 parent 882390c commit b73ff8b

36 files changed

+966
-406
lines changed

.github/workflows/ci.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request: {}
9+
10+
11+
jobs:
12+
13+
build:
14+
name: cargo build
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
- name: Build
20+
run: cargo build
21+
22+
test:
23+
name: cargo test
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: dtolnay/rust-toolchain@stable
28+
with:
29+
components: rustfmt clippy
30+
- name: rustfmt
31+
run: cargo fmt --all -- --check
32+
- name: clippy
33+
run: cargo clippy
34+
- name: test
35+
run: cargo test --verbose

.gitignore

+48-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
### JetBrains template
1+
# Created by https://www.toptal.com/developers/gitignore/api/rust,macos,jetbrains+all
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,macos,jetbrains+all
3+
4+
### JetBrains+all ###
25
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
36
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
47

@@ -77,7 +80,49 @@ fabric.properties
7780
# Android studio 3.1+ serialized cache file
7881
.idea/caches/build_file_checksums.ser
7982

80-
### Rust template
83+
### JetBrains+all Patch ###
84+
# Ignore everything but code style settings and run configurations
85+
# that are supposed to be shared within teams.
86+
87+
.idea/*
88+
89+
!.idea/codeStyles
90+
!.idea/runConfigurations
91+
92+
### macOS ###
93+
# General
94+
.DS_Store
95+
.AppleDouble
96+
.LSOverride
97+
98+
# Icon must end with two \r
99+
Icon
100+
101+
102+
# Thumbnails
103+
._*
104+
105+
# Files that might appear in the root of a volume
106+
.DocumentRevisions-V100
107+
.fseventsd
108+
.Spotlight-V100
109+
.TemporaryItems
110+
.Trashes
111+
.VolumeIcon.icns
112+
.com.apple.timemachine.donotpresent
113+
114+
# Directories potentially created on remote AFP share
115+
.AppleDB
116+
.AppleDesktop
117+
Network Trash Folder
118+
Temporary Items
119+
.apdisk
120+
121+
### macOS Patch ###
122+
# iCloud generated files
123+
*.icloud
124+
125+
### Rust ###
81126
# Generated by Cargo
82127
# will have compiled files and executables
83128
debug/
@@ -93,3 +138,4 @@ Cargo.lock
93138
# MSVC Windows builds of rustc generate these, which store debugging information
94139
*.pdb
95140

141+
# End of https://www.toptal.com/developers/gitignore/api/rust,macos,jetbrains+all

Cargo.toml

+29-24
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,40 @@ members = [
33
"crates/*"
44
]
55

6+
resolver = "2"
7+
68
[workspace.package]
7-
version = "0.0.1-alpha.1"
8-
authors = ["Benedikt Schwab"]
9+
version = "0.0.1-alpha.3"
10+
authors = ["Benedikt Schwab <benedikt.schwab@gmail.com>"]
911
edition = "2021"
1012
license = "MIT OR Apache-2.0"
11-
repository = "https://github.com/tum-gis/erosbag"
13+
repository = "https://github.com/envis-space/erosbag"
1214

1315
[workspace.dependencies]
14-
epoint = { version = "0.0.1-alpha", registry = "custom" }
15-
ecoord = { version = "0.0.1-alpha", registry = "custom" }
16+
epoint = { version = "0.0.1-alpha.3" }
17+
eimage = { version = "0.0.1-alpha.3" }
18+
ecoord = { version = "0.0.1-alpha.3" }
1619

17-
clap = "4.0.4"
18-
dotenvy = "0.15.0"
19-
walkdir = "2.3.2"
20-
tracing = "0.1.30"
21-
tracing-subscriber = "0.3.8"
22-
diesel = "2.0.2"
23-
diesel_migrations = "2.0.0"
24-
serde = "1.0"
25-
serde_derive = "1.0.143"
26-
serde_repr = "0.1"
27-
serde_yaml = "0.9"
28-
serde-big-array = "0.4.1"
20+
clap = "4.5.9"
21+
dotenvy = "0.15.7"
22+
walkdir = "2.5.0"
23+
tracing = "0.1.40"
24+
tracing-subscriber = "0.3.18"
25+
diesel = "~2.1.6"
26+
diesel_migrations = "~2.1.0"
27+
r2d2 = "0.8.10"
28+
serde = "1.0.204"
29+
serde_derive = "1.0.204"
30+
serde_repr = "0.1.19"
31+
serde_yaml = "0.9.34"
32+
serde-big-array = "0.5.1"
2933
cdr = "0.2.4"
30-
thiserror = "1.0.35"
31-
polars = "0.26.1"
34+
thiserror = "1.0.61"
35+
polars = "0.41.3"
3236
ndarray = "0.15.6"
33-
indextree = "4.4.0"
34-
rayon = "1.5.3"
35-
nalgebra = "0.31.1"
36-
chrono = "0.4.22"
37-
itertools = "0.10.5"
37+
indextree = "4.6.1"
38+
rayon = "1.10.0"
39+
nalgebra = "0.33.0"
40+
chrono = "0.4.38"
41+
itertools = "0.13.0"
42+
image = "0.25.1"

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
# erosbag
2+
3+
A Rust library for processing ROS2 bags.
4+
5+
> [!WARNING]
6+
> The library is at an early stage of development.
7+
8+
## Contributing
9+
10+
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome.

crates/erosbag-cli/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ authors.workspace = true
55
edition.workspace = true
66
license.workspace = true
77
repository.workspace = true
8-
description = "CLI tool for Rosbag operations"
8+
description = "CLI tool for processing ROS2 bags."
99

1010

1111
[dependencies]
12-
erosbag = { version = "0.0.1-alpha.1", path = "../erosbag", registry = "custom" }
12+
erosbag = { version = "0.0.1-alpha.3", path = "../erosbag" }
1313
ecoord = { workspace = true }
1414
epoint = { workspace = true }
15+
eimage = { workspace = true }
1516

1617
clap = { workspace = true, features = ["derive"] }
1718
dotenvy = { workspace = true }

crates/erosbag-cli/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# erosbag-cli
2+
3+
CLI tool for processing ROS2 bags.
4+
5+
> [!WARNING]
6+
> The library is at an early stage of development.
7+
8+
## Contributing
9+
10+
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome.

crates/erosbag-cli/src/arguments.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,45 @@ pub enum Commands {
1616
rosbag_directory_path: String,
1717
},
1818

19-
/// Extract the transforms to an ecoord document
19+
/// Extract the transforms
2020
ExtractTransforms {
2121
/// Path to the ROS2 bag
2222
#[clap(long)]
2323
rosbag_directory_path: String,
2424

25-
/// Path to the ecoord document
25+
/// Path to the output ecoord file
2626
#[clap(long)]
27-
output_ecoord_file_path: String,
27+
output_ecoord_path: String,
2828
},
2929

30-
/// Extract point clouds accumulated over time
30+
/// Extract the point clouds
3131
ExtractPointClouds {
3232
/// Path to the ROS2 bag
3333
#[clap(long)]
3434
rosbag_directory_path: String,
3535

36-
/// Path to output directory of extracted point clouds
36+
/// Path to the ecoord document
37+
#[clap(long)]
38+
ecoord_file_path: Option<String>,
39+
40+
/// Target frame id of extracted point cloud
41+
#[clap(long)]
42+
frame_id: Option<String>,
43+
44+
/// Path to the output epoint file containing the extracted point clouds
3745
#[clap(long)]
38-
output_directory_path: String,
46+
output_epoint_path: String,
3947
},
4048

41-
/// Extract images
49+
/// Extract the images
4250
ExtractImages {
4351
/// Path to the ROS2 bag
4452
#[clap(long)]
4553
rosbag_directory_path: String,
4654

47-
/// Path to output directory of extracted images
55+
/// Path to output eimage file containing the extracted images
4856
#[clap(long)]
49-
output_directory_path: String,
57+
output_eimage_path: String,
5058
},
5159

5260
/// Append the reference frames to a ROS bag

crates/erosbag-cli/src/commands/extract_image_data.rs

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use chrono::{DateTime, Duration, TimeZone, Utc};
2+
use ecoord::{FrameId, ReferenceFrames};
3+
use eimage::{ImageCollection, ImageSeries};
4+
use erosbag::RosbagOpenOptions;
5+
use std::collections::HashMap;
6+
7+
use std::path::Path;
8+
use tracing::info;
9+
10+
pub fn run(rosbag_directory_path: impl AsRef<Path>, output_eimage_path: impl AsRef<Path>) {
11+
info!("Start extracting images");
12+
info!("Rosbag path: {}", rosbag_directory_path.as_ref().display());
13+
info!(
14+
"Output eimage path: {}",
15+
output_eimage_path.as_ref().display()
16+
);
17+
18+
// fs::create_dir_all(output_file_path).unwrap();
19+
20+
let rosbag = RosbagOpenOptions::new()
21+
.read_write(true)
22+
.open(rosbag_directory_path.as_ref())
23+
.unwrap();
24+
25+
let start_time: Option<DateTime<Utc>> =
26+
Some(Utc.timestamp_nanos(1579007185814586880 + 1000000000) + Duration::seconds(5));
27+
let stop_time: Option<DateTime<Utc>> = start_time.map(|x| x + Duration::seconds(5));
28+
29+
let image_series = rosbag
30+
.get_images(
31+
&"/camera_side_left/rgb/image_rect_color".to_string(),
32+
&start_time,
33+
&stop_time,
34+
)
35+
.unwrap();
36+
info!("Extracted {} images.", image_series.len());
37+
let mut image_series_map: HashMap<FrameId, ImageSeries> = HashMap::new();
38+
image_series_map.insert(FrameId::from("camera_side_left"), image_series);
39+
let image_collection =
40+
ImageCollection::new(image_series_map, ReferenceFrames::default()).unwrap();
41+
eimage::io::EimageWriter::from_path(output_eimage_path)
42+
.unwrap()
43+
.finish(image_collection)
44+
.unwrap();
45+
}

0 commit comments

Comments
 (0)