Crate nri [stability]
[-] [+]
[src]
This crate contains all the software used to run the sensing rig. It's designed to run on the Intel NUC in the rig operator's backpack. There are driver wrappers for each sensor, a supervisor that runs each of those in its own thread, plus CLI and web interfaces to control everything.
How to...
... generate this documentation
- Run cargo doc in the NRI repo:
nri$ cargo doc
- Now we need the rustdoc command for this crate.
nri$ touch src/main.rs nri$ cargo doc -v | grep rustdoc | awk "-FRunning " '{print substr($NF, 2, length($NF)-2)}' > cargo-doc-command
- Edit
cargo-doc-command
and add--no-defaults --passes "collapse-docs" --passes "unindent-comments"
aftersrc/main.rs
. Then run it.
nri$ source cargo-doc-command
- You can now access the docs at
target/doc/nri/index.html
. If you want them on the web: copy the docs to the Github Pages repo, commit, and push.
nri$ pushd ../haptics-nri.github.io haptics-nri.github.io$ git pull haptics-nri.github.io$ popd nri$ rsync -a target/doc ../haptics-nri.github.io nri$ pushd ../haptics-nri.github.io haptics-nri.github.io$ git add doc haptics-nri.github.io$ git commit -m "cargo doc" haptics-nri.github.io$ git push haptics-nri.github.io$ popd
- The docs are now live (after 30s or so) at http://haptics-nri.github.io/doc/nri.
... lint this code
- The script
clippy.sh
modifies Cargo.toml and src/main.rs to include rust-clippy, changes the toolchain to nightly (using multirust), runscargo run
to generate all the lint warnings, and then switches everything back.
... set up the wi-fi hotspot
I followed the instructions here to create a Wi-Fi hotspot to which Android devices can connect. Unity's built in network manager can almost, but not quite, do it. You need to create the network in the manager and then go edit the file to change it from Infrastructure Mode to AP Mode (which is not an option in the GUI -- you can select Ad-hoc Mode, but Android won't connect to that).
Shortened instructions:
- Click on the network icon in the system tray. Select "Edit connections...".
- Click "Add".
- Choose "Wi-Fi" for the type and click Create.
- Make up an SSID. Leave the type as "Infrastructure" (it doesn't matter, since we'll change it manually). Select the wireless card in the "Device MAC address" dropdown.
- Go to the "Wi-Fi Security" tab and choose sane options.
- Go to the "IPv4 Settings" tab and set the Method to "Shared to other computers".
- Click Save.
- Edit the file
/etc/NetworkManager/system-connections/$SSID
and changemode=infrastructure
tomode=ap
. - Deactivate and reactivate Wi-Fi. Then you should be able to select the new SSID to "connect" (meaning broadcast). And then you should be able to connect from other devices!
Note that (obviously) when the NUC is running as a hotspot, it has no internet connection. I
tried to get DNS running, but I failed, so for now you have to use an IP address to access the
NUC. You can see what it chose by running hostname -I
-- it seems to like 10.42.0.1.
Reexports
extern crate "std" as std; |
extern crate log; |
extern crate env_logger; |
use std::prelude::v1::*; |
use std::io; |
use std::io::{Write, BufRead}; |
use std::ascii::AsciiExt; |
use std::ptr; |
use std::thread; |
use std::sync::mpsc::{channel, Sender, Receiver, TryRecvError}; |
use std::process::Command; |
use mpmc::MultiSender; |
use comms::{CmdTo, CmdFrom}; |
use cli::CLI; |
use web::Web; |
use structure::Structure; |
use bluefox::Bluefox; |
use optoforce::Optoforce; |
Modules
bluefox | Service to capture frames from the mvBlueFOX3 camera |
cli | CLI interface to view and control running services |
comms | Utilities for communication between the supervisor thread and services |
mpmc | Multi-producer/multi-consumer channels |
optoforce | Service to read data from the OptoForce sensor |
structure | Service to capture frames from the Structure Sensor |
web | Web interface to view and control running services |
Macros
rpc! | Convenience macro for making an "RPC" call from a service up to the main thread. This is done by generating a nonce channel, stuffing the sending end into a message that gets sent to the main thread, and then waiting for the main thread to send back a reply. |
Structs
Service | Service descriptor |
Functions
main | Main function that does everything |
send_to | |
start | |
stop | |
stop_all |