#Rust

Rust

Rust samples

This article provides some code samples in Rust.

Command line interface

Command arguments

cargo run foo bar baz "This string is a sentence"
1use std::env;
2
3// cargo run hello world
4
5fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 // Retrieve first argument
9 let input = args[1].clone();
10
11 // Print all arguments
12 println!("{:?}", args); // ["target/debug/executable", "foo", "bar", "baz", "This string is a sentence"]
13}

Standard input

1use std::io;
2
3fn main() {
4 // empty string
5 let mut input = String::new();
6
7 // Collecting user input
8 println!("Enter your name: ");
9 io::stdin()
10 .read_line(&mut input)
11 .expect("Failed to read line");
12
13 println!("Received name: {}", input);
14}
15
Rust

UVT-RS

A blazingly fast trajectory description file format

· 2min · Damien LaRocque
cover

During the last months, I worked on uvt-rs, my first project in Rust 🦀!

uvt-rs is a collection of Rust crates for processing and interacting with Uncrewed Vehicle Trajectory (UVT) files. The UVT file format provides a lightweight way to describe trajectories of uncrewed vehicles, such as UAV, UGV, etc. It was designed as an extension of the LTR format introduced in Kilometer-Scale Autonomous Navigation in Subarctic Forests: Challenges and Lessons Learned.

The repository includes three crates:

  • uvt, to read, write, and generate UVT files from ROS bags (.bag) and MCAP files
  • uvt-plot, to plot a bird's-eye view of recorded trajectories
  • uvt-viz3d, to visualize UVT files in 3D with rerun

Through this project, I learned a lot about coding and packaging Rust crates, and I gained experience with deserializing messages from both ROS bag and MCAP formats. I'm now looking forward to more opportunities to use Rust for robotics projects!

<video controls autoplay
    muted>
    <source src="uvt-preview.mp4" type="video/mp4" />
    Your browser doesn't support the video tag and/or the video formats in use here – sorry!
</video><div class="galleria mb-6" style="height: 450px;">
{

"images": [ { "src": "rerun02.png", "title": "A UVT file visualized in rerun"}, { "src": "rerun01.png", "title": "A UVT file visualized in rerun"}, { "src": "traj-plot.png", "title": "Trajectory plotted with uvt-plot."} ] }

For more info,

UVT-RS