-
Notifications
You must be signed in to change notification settings - Fork 7
Support new GPS #151
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
Merged
onkoe
merged 9 commits into
Sooner-Rover-Team:main
from
onkoe:feat/septentrio_mosaic_go_gps
Feb 17, 2026
Merged
Support new GPS #151
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a90bc18
docs: add info about new GPS
onkoe 90d3471
feat(soro_gps): add serial-based conn for gps
onkoe 3a2c81e
feat(soro_gps): add gps connection example
onkoe 8938a9b
feat(soro_gps): finish septentrio parser
onkoe f7e71e4
test(soro_gps): add gps test files (real data)
onkoe 6f9a091
docs(soro_gps): add some test notes to README
onkoe 59e072b
chore(soro_gps): add `/dev` note to laptop example
onkoe ee85590
test(soro_gps): add regression test w/ fr values
onkoe 04ce46e
docs(soro_gps): add info about east, north, up
onkoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,13 @@ | ||
| <!-- cargo-rdme start --> | ||
| # `soro_gps` | ||
|
|
||
| # `gps-rs` | ||
| Connects to the GPS and provides its data in a readable format. | ||
|
|
||
| Bindings to the Swift GPS library ([`gps/`](https://github.com/Sooner-Rover-Team/gps)). | ||
| ## Testing | ||
|
|
||
| This crate exposes the `bindings` module to access the C functions and statics directly. | ||
| To test the GPS connection, use the following command: | ||
|
|
||
| However, intended usage is through the `Gps` struct, which provides a safe wrapper for the unsafe C items. | ||
| `timeout 3s sh -c 'dd if=/dev/serial/by-id/usb-Septentrio_Septentrio_USB_Device_3844945-if02 bs=1 count=64 status=none | xxd -g 1 -u'` | ||
|
|
||
| This type exposes safe bindings with respect to the (kinda undocumented) safety constraints of the C code. Previous testing shows that violating these unspoken invariants can result in all kinds of weird behavior! | ||
| If that works, great! Otherwise, you'll want to find the device path: `ls /dev/serial/by-id/ | grep Septentrio`. Then, replace the path in the command above with the one you got from that command. If there's multiple, test them all. | ||
|
|
||
| ## Usage (Rust) | ||
|
|
||
| In short, you can use the various methods on `Gps` to interact with the Rover's GPS system. | ||
|
|
||
| ```rust | ||
| use gps_rs::Gps; | ||
|
|
||
| // we can make a GPS from a given IP address and port. | ||
| // | ||
| // on the Rover, this is from the router (hopefully a static IP) and a port | ||
| let swift_ip: IpAddr = "192.168.1.222".parse().unwrap(); | ||
| let swift_port: u16 = 55556; | ||
|
|
||
| // here, we make the GPS! this will automatically initialize it. | ||
| let gps: Gps = Gps::new(swift_ip, swift_port).unwrap(); | ||
|
|
||
| // now, you can use its methods: | ||
| println!("coord: {:?}", gps.coord()); | ||
| println!("height: {:?}", gps.height()); | ||
| println!("error in mm: {:?}", gps.error()); | ||
|
|
||
| // dropping it (when it falls from scope) automatically runs the required cleanup. | ||
| ``` | ||
|
|
||
| ## Usage (Python) | ||
|
|
||
| Unimplemented. This should use the `pyo3` feature to build, and I'll plan to upload it to PyPi soon. | ||
|
|
||
| <!-- cargo-rdme end --> | ||
| On the other hand, if none of those work, you should try configuring the streams on the GPS receiver. Ensure it's plugged into a computer with a display (like a laptop), then navigate to [its configuration page](http://192.168.3.1) and select the "NMEA/SBF Out" tab. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //! This example should work on a laptop/desktop computer. | ||
| //! | ||
| //! I'm using it now to test the GPS connection without any ROS 2 stuff to mess | ||
| //! with anything. | ||
|
|
||
| use soro_gps::Gps; | ||
|
|
||
| fn main() { | ||
| // IMPORTANT: change this to the GPS' serial connection file. | ||
| // | ||
| // on Windows, you might be outta luck, but macOS and Linux should allow | ||
| // grabbing this with: `ls /dev/serial/by-id | grep Septentrio` | ||
| const DEVICE_PATH: &str = "/dev/ttyACM0"; | ||
|
|
||
| // then, "make a connection" by reading from that file! | ||
| let mut gps: Gps = match Gps::new(DEVICE_PATH.into()) { | ||
| Ok(gps) => gps, | ||
| Err(e) => { | ||
| tracing::error!("GPS connection error: {e}"); | ||
| panic!(); | ||
| } | ||
| }; | ||
|
|
||
| // continuously grab GPS information | ||
| loop { | ||
| match gps.get() { | ||
| Some(gps_info) => { | ||
| tracing::info!("New GPS message: {gps_info:?}") | ||
| } | ||
|
|
||
| Option::None => { | ||
| tracing::error!("GPS disconnected! Waiting 2s and trying again..."); | ||
| std::thread::sleep(core::time::Duration::from_millis(2_000)); | ||
| continue; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,40 @@ | ||
| use core::error::Error; | ||
| use std::time::Duration; | ||
| use std::path::PathBuf; | ||
|
|
||
| /// An error that can occur when connecting to the GPS. | ||
| #[derive(Debug, pisserror::Error)] | ||
| #[derive(Clone, Debug)] | ||
| pub enum GpsConnectionError { | ||
| #[error("Failed to bind to the provided port. port: {port}, err: {err}")] | ||
| BindError { port: u16, err: std::io::Error }, | ||
|
|
||
| #[error("Couldn't connect to the provided address and port. err: {_0}")] | ||
| ConnectionError(#[from] std::io::Error), | ||
| /// The GPS' serial output file representation was not found at the given | ||
| /// location. | ||
| FileNotFound( | ||
| /// The given location. | ||
| PathBuf, | ||
| ), | ||
| /// The GPS path exists, but opening it as a serial source failed. | ||
| FailedToOpen( | ||
| /// The given location. | ||
| PathBuf, | ||
| /// Details from the OS/driver stack. | ||
| String, | ||
| ), | ||
| } | ||
|
|
||
| /// An error that may occur when reading from the GPS. | ||
| #[derive(Debug, pisserror::Error)] | ||
| pub enum GpsReadError { | ||
| #[error("GPS can't update that fast. elapsed: {} ms", elapsed.as_millis())] | ||
| HaventHitUpdateTime { elapsed: Duration }, | ||
|
|
||
| #[error("Failed to read before hitting the timeout. timeout: {} ms", _0.as_millis())] | ||
| HitTimeout(Duration), | ||
|
|
||
| #[error("Failed to read from the socket.")] | ||
| ReadFailed, | ||
| impl core::error::Error for GpsConnectionError {} | ||
|
|
||
| #[error("Parsing failed.")] | ||
| ParseFailed(#[from] sbp::Error), | ||
| impl core::fmt::Display for GpsConnectionError { | ||
| fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { | ||
| match self { | ||
| GpsConnectionError::FileNotFound(serial_path) => write!( | ||
| f, | ||
| "The GPS' serial output file representation was not found at \ | ||
| the given location: `{}`", | ||
| serial_path.to_string_lossy() | ||
| ), | ||
| GpsConnectionError::FailedToOpen(serial_path, reason) => write!( | ||
| f, | ||
| "Failed to open GPS source at `{}`: {}", | ||
| serial_path.to_string_lossy(), | ||
| reason | ||
| ), | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.