openrr_apps_joint_position_sender/
joint_position_sender.rs

1use std::path::PathBuf;
2
3use anyhow::Result;
4use clap::Parser;
5use openrr_apps::utils::init_tracing;
6use openrr_client::BoxRobotClient;
7use tracing::debug;
8
9/// An openrr GUI tool to send joint positions.
10#[derive(Parser, Debug)]
11#[clap(name = env!("CARGO_BIN_NAME"))]
12struct Opt {
13    /// Path to the setting file.
14    #[clap(short, long, value_parser)]
15    config_path: Option<PathBuf>,
16    /// Set options from command line. These settings take priority over the
17    /// setting file specified by --config-path.
18    #[clap(long)]
19    config: Option<String>,
20}
21
22fn main() -> Result<()> {
23    init_tracing();
24    let opt = Opt::parse();
25    debug!("opt: {opt:?}");
26
27    let config_path = openrr_apps::utils::get_apps_robot_config(opt.config_path);
28    let config =
29        openrr_apps::utils::resolve_robot_config(config_path.as_deref(), opt.config.as_deref())?;
30
31    openrr_apps::utils::init(env!("CARGO_BIN_NAME"), &config);
32    let client: BoxRobotClient = config.create_robot_client()?;
33    let robot = match config.openrr_clients_config.urdf_full_path() {
34        Some(path) => urdf_rs::utils::read_urdf_or_xacro(path)?,
35        None => arci_urdf_viz::UrdfVizWebClient::default().get_urdf()?,
36    };
37    openrr_gui::joint_position_sender(client, robot)?;
38    Ok(())
39}
40
41#[cfg(test)]
42mod tests {
43    use clap::CommandFactory;
44
45    use super::*;
46
47    #[test]
48    fn assert_app() {
49        Opt::command().debug_assert();
50    }
51}