-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved the config generation example to its own
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,3 +1,3 @@ | ||
[workspace] | ||
members = ["copper", "copper_derive", "copper_derive_test", "examples/pluginload", "examples/simplelogger", "examples/v4lsrc"] | ||
members = ["copper", "copper_derive", "copper_derive_test", "examples/config-gen", "examples/pluginload", "examples/simplelogger", "examples/v4lsrc"] | ||
resolver = "2" |
This file contains 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,9 @@ | ||
[package] | ||
name = "config-gen" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
copper = { path = "../../copper"} | ||
uom = "0.36.0" |
This file contains 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,29 @@ | ||
use uom::si::time::second; | ||
use uom::si::time::Time; | ||
|
||
use copper::config::ConfigNode; | ||
use copper::config::CopperConfig; | ||
use copper::config::Value; | ||
|
||
/// This is a simple example to show how to programmatically generate a configuration. | ||
/// This is useful for making variations of your robot more easily. | ||
fn main() { | ||
// Generate a config | ||
let mut copperconfig = CopperConfig::new(); | ||
let mut camera = | ||
ConfigNode::new("camera", "camerapkg::Camera") | ||
.set_base_period(Time::new::<second>(60.into())); | ||
camera.set_param::<Value>("resolution-height", 1080.into()); | ||
let isp = | ||
ConfigNode::new("copper-isp", "isppkg::Isp").set_base_period(Time::new::<second>(1.into())); | ||
// isp.set_param::<Value>("tone", 1.3.into()); | ||
let algo = ConfigNode::new("copper-algo", "algopkg::Algo") | ||
.set_base_period(Time::new::<second>(5.into())); | ||
let n1 = copperconfig.add_node(isp); | ||
let n2 = copperconfig.add_node(camera); | ||
let n3 = copperconfig.add_node(algo); | ||
|
||
copperconfig.connect(n2, n1, "imgmsgpkg::Image"); | ||
copperconfig.connect(n1, n3, "imgmsgpkg::Image"); | ||
println!("{}", copperconfig.serialize()); | ||
} |