Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
benediktschwab committed Jul 9, 2024
1 parent 882390c commit b73ff8b
Show file tree
Hide file tree
Showing 36 changed files with 966 additions and 406 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request: {}


jobs:

build:
name: cargo build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build

test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt clippy
- name: rustfmt
run: cargo fmt --all -- --check
- name: clippy
run: cargo clippy
- name: test
run: cargo test --verbose
50 changes: 48 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
### JetBrains template
# Created by https://www.toptal.com/developers/gitignore/api/rust,macos,jetbrains+all
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,macos,jetbrains+all

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

Expand Down Expand Up @@ -77,7 +80,49 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Rust template
### JetBrains+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
Expand All @@ -93,3 +138,4 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# End of https://www.toptal.com/developers/gitignore/api/rust,macos,jetbrains+all
53 changes: 29 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,40 @@ members = [
"crates/*"
]

resolver = "2"

[workspace.package]
version = "0.0.1-alpha.1"
authors = ["Benedikt Schwab"]
version = "0.0.1-alpha.3"
authors = ["Benedikt Schwab <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/tum-gis/erosbag"
repository = "https://github.com/envis-space/erosbag"

[workspace.dependencies]
epoint = { version = "0.0.1-alpha", registry = "custom" }
ecoord = { version = "0.0.1-alpha", registry = "custom" }
epoint = { version = "0.0.1-alpha.3" }
eimage = { version = "0.0.1-alpha.3" }
ecoord = { version = "0.0.1-alpha.3" }

clap = "4.0.4"
dotenvy = "0.15.0"
walkdir = "2.3.2"
tracing = "0.1.30"
tracing-subscriber = "0.3.8"
diesel = "2.0.2"
diesel_migrations = "2.0.0"
serde = "1.0"
serde_derive = "1.0.143"
serde_repr = "0.1"
serde_yaml = "0.9"
serde-big-array = "0.4.1"
clap = "4.5.9"
dotenvy = "0.15.7"
walkdir = "2.5.0"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
diesel = "~2.1.6"
diesel_migrations = "~2.1.0"
r2d2 = "0.8.10"
serde = "1.0.204"
serde_derive = "1.0.204"
serde_repr = "0.1.19"
serde_yaml = "0.9.34"
serde-big-array = "0.5.1"
cdr = "0.2.4"
thiserror = "1.0.35"
polars = "0.26.1"
thiserror = "1.0.61"
polars = "0.41.3"
ndarray = "0.15.6"
indextree = "4.4.0"
rayon = "1.5.3"
nalgebra = "0.31.1"
chrono = "0.4.22"
itertools = "0.10.5"
indextree = "4.6.1"
rayon = "1.10.0"
nalgebra = "0.33.0"
chrono = "0.4.38"
itertools = "0.13.0"
image = "0.25.1"
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# erosbag

A Rust library for processing ROS2 bags.

> [!WARNING]
> The library is at an early stage of development.
## Contributing

The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome.
5 changes: 3 additions & 2 deletions crates/erosbag-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "CLI tool for Rosbag operations"
description = "CLI tool for processing ROS2 bags."


[dependencies]
erosbag = { version = "0.0.1-alpha.1", path = "../erosbag", registry = "custom" }
erosbag = { version = "0.0.1-alpha.3", path = "../erosbag" }
ecoord = { workspace = true }
epoint = { workspace = true }
eimage = { workspace = true }

clap = { workspace = true, features = ["derive"] }
dotenvy = { workspace = true }
Expand Down
10 changes: 10 additions & 0 deletions crates/erosbag-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# erosbag-cli

CLI tool for processing ROS2 bags.

> [!WARNING]
> The library is at an early stage of development.
## Contributing

The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome.
26 changes: 17 additions & 9 deletions crates/erosbag-cli/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,45 @@ pub enum Commands {
rosbag_directory_path: String,
},

/// Extract the transforms to an ecoord document
/// Extract the transforms
ExtractTransforms {
/// Path to the ROS2 bag
#[clap(long)]
rosbag_directory_path: String,

/// Path to the ecoord document
/// Path to the output ecoord file
#[clap(long)]
output_ecoord_file_path: String,
output_ecoord_path: String,
},

/// Extract point clouds accumulated over time
/// Extract the point clouds
ExtractPointClouds {
/// Path to the ROS2 bag
#[clap(long)]
rosbag_directory_path: String,

/// Path to output directory of extracted point clouds
/// Path to the ecoord document
#[clap(long)]
ecoord_file_path: Option<String>,

/// Target frame id of extracted point cloud
#[clap(long)]
frame_id: Option<String>,

/// Path to the output epoint file containing the extracted point clouds
#[clap(long)]
output_directory_path: String,
output_epoint_path: String,
},

/// Extract images
/// Extract the images
ExtractImages {
/// Path to the ROS2 bag
#[clap(long)]
rosbag_directory_path: String,

/// Path to output directory of extracted images
/// Path to output eimage file containing the extracted images
#[clap(long)]
output_directory_path: String,
output_eimage_path: String,
},

/// Append the reference frames to a ROS bag
Expand Down
16 changes: 0 additions & 16 deletions crates/erosbag-cli/src/commands/extract_image_data.rs

This file was deleted.

45 changes: 45 additions & 0 deletions crates/erosbag-cli/src/commands/extract_images.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use chrono::{DateTime, Duration, TimeZone, Utc};
use ecoord::{FrameId, ReferenceFrames};
use eimage::{ImageCollection, ImageSeries};
use erosbag::RosbagOpenOptions;
use std::collections::HashMap;

use std::path::Path;
use tracing::info;

pub fn run(rosbag_directory_path: impl AsRef<Path>, output_eimage_path: impl AsRef<Path>) {
info!("Start extracting images");
info!("Rosbag path: {}", rosbag_directory_path.as_ref().display());
info!(
"Output eimage path: {}",
output_eimage_path.as_ref().display()
);

// fs::create_dir_all(output_file_path).unwrap();

let rosbag = RosbagOpenOptions::new()
.read_write(true)
.open(rosbag_directory_path.as_ref())
.unwrap();

let start_time: Option<DateTime<Utc>> =
Some(Utc.timestamp_nanos(1579007185814586880 + 1000000000) + Duration::seconds(5));
let stop_time: Option<DateTime<Utc>> = start_time.map(|x| x + Duration::seconds(5));

let image_series = rosbag
.get_images(
&"/camera_side_left/rgb/image_rect_color".to_string(),
&start_time,
&stop_time,
)
.unwrap();
info!("Extracted {} images.", image_series.len());
let mut image_series_map: HashMap<FrameId, ImageSeries> = HashMap::new();
image_series_map.insert(FrameId::from("camera_side_left"), image_series);
let image_collection =
ImageCollection::new(image_series_map, ReferenceFrames::default()).unwrap();
eimage::io::EimageWriter::from_path(output_eimage_path)
.unwrap()
.finish(image_collection)
.unwrap();
}
Loading

0 comments on commit b73ff8b

Please sign in to comment.