Expand description
§Rust Robotics ToolKit
A set of algorithms and other tools for robotics in Rust.
It is almost entirely no_std
and most things work without alloc
. It does not currently integrate with any API directly. This may be added in the future, probably through another crate.
§Feature Flags
alloc
- Enable items requiring dynamic allocation through Rust’s builtinalloc
crate.std
- Enable items requiring the Rust standard library. Requiresalloc
feature. Enabled by default.devices
- Enable RRTK’s graph-based device system.dim_check_debug
- Enable dimension checking in debug mode. Enabled by default.dim_check_release
- Enable dimension checking in both debug mode and release mode. Requiresdim_check_debug
feature.libm
- Uselibm
for float exponentiation whenstd
is not available.micromath
- Usemicromath
for float exponentiation whenstd
andlibm
are unavailable.
RRTK prefers std
over libm
and libm
over micromath
when multiple are
available.
Re-exports§
pub use reference::rc_ref_cell_reference;
pub use reference::Reference;
pub use reference::arc_mutex_reference;
pub use reference::arc_rw_lock_reference;
pub use dimensions::*;
Modules§
- devices
- RRTK’s device system works through a graph-like structure where each device holds objects called
terminals in
RefCell
s. Terminals represent anywhere that a device can connect to another. Connected terminals hold references to eachother’sRefCell
s. This module holds builtin devices. - dimensions
- This module contains types related to RRTK’s dimensional analysis system. RRTK uses nanoseconds for time because they typically work nicely with computer clocks and are still precise when stored in an integer, which is important because exponentially losing precision for time is bad, and float time does that. However, floats are used for other quantities, including quantities derived from time. These use seconds instead because numbers of the magnitude of nanoseconds cause floats to lose precision. RRTK should handle the conversion mostly seamlessly for you, but keep it in mind when thinking about how time-related types should work. The reasoning behind this unorthodox system using both nanoseconds and seconds becomes more apparent when you know how floating point numbers work. Everything in this module is reexported at the crate level.
- reference
Reference
is a container holding an enum with variants containing different kinds of references, the availability of some of which depends on crate features.Reference
is borrowed like aRefCell
. This module contains it and its related types.Reference
is also reexported at the crate level.- streams
- Getters that do data processing and have other getters as inputs are called streams. These are
some helpful builtin streams for controlling your robot. See the
pid
example to learn more about how to use the stream system.
Macros§
- static_
mutex_ reference - Create a new static
Mutex
of something and return aPtrMutex
-variantReference
to it. - static_
reference - Create a static of something and return a
Ptr
-variantReference
to it. This contains a raw mutable pointer. It will never use-after-free because its target is static, but be careful if you’re doing multiprocessing where multiple things could mutate it at once. - static_
rw_ lock_ reference - Create a static
RwLock
of something and return aPtrRwLock
-variantReference
to it. - to_dyn
- If you have a
Reference<Foo>
whereFoo
implements theBar
trait, you may end up wanting aReference<dyn Bar>
. To convert it, you would do this:
Structs§
- Constant
Getter - Getter for returning a constant value.
- Datum
- A container for a time and something else, usually an
f32
or aState
. - Getter
From History - As histories return values at times, we can ask them to return values at the time of now or now
with a delta. This makes that much easier and is the recommended way of following
MotionProfile
s. - Motion
Profile - A motion profile for getting from one state to another.
- None
Getter - Getter always returning
Ok(None)
. - PIDK
Values - Coefficients for a PID controller.
- Position
Derivative DependentPIDK Values - A set of PID k-values for controlling each position derivative.
- Settable
Data - Internal data needed for following a
Getter
with aSettable
. - State
- A one-dimensional motion state with position, velocity, and acceleration.
- Terminal
- A place where a device can connect to another.
- Terminal
Data - Data that are sent between terminals: A timestamp, an optional command, and a state.
- Time
Getter From Getter - Because
Getter
s always return a timestamp (as long as they don’t returnErr(_)
orOk(None)
), we can use this to treat them likeTimeGetter
s.
Enums§
- Command
- A command for a motor to perform: go to a position, run at a velocity, or accelerate at a rate.
- Error
- RRTK follows the enum style of error handling. This is the error type returned from nearly all
RRTK types, but you can add your own custom error type using
Other(O)
. It is strongly recommended that you use a singleO
type across your crate. - Motion
Profile Piece - Where you are in following a motion profile.
- Position
Derivative - A derivative of position: position, velocity, or acceleration.
Traits§
- Device
- A mechanical device.
- Getter
- Something with a
get
method. Structs implementing this will often be chained for easier data processing, with a struct having other implementors in fields which will have some operation performed on their output before it being passed on. Data processing Getters with other Getters as fields can be referred to as streams, though this is only in naming and trait-wise there is no distinction. The other common use for this trait is encoders. These should not be called streams. - History
- An object that can return a value, like a
Getter
, for a given time. - Option
Datum Ext - Extension trait for
Option<Datum<T>>
. - Settable
- Something with a
set
method. Usually used for motors and other mechanical components and systems. This trait too is fairly broad. - Time
Getter - An object for getting the absolute time.
- Updatable
- Something with an
update
method. Mostly for subtraiting.
Functions§
- connect
- Connect two terminals. Connected terminals should represent a physical connection between
mechanical devices. This function will automatically disconnect the specified terminals if they
are connected. You can manually disconnect terminals by calling the
disconnect
method on either of them. - latest
- Get the newer of two
Datum
objects.
Type Aliases§
- Nothing
OrError - Returned when something may return either nothing or an error.
- Output
- A generic output type when something may return an error, nothing, or something with a timestamp.
- Time
Output - Returned from
TimeGetter
objects, which may return either a time or an error.