Skip to content

Template for entering the ICRA 2023 Humanoid Robot Wrestling competition with a controller written in Rust.

License

Notifications You must be signed in to change notification settings

katharostech/icra-2023-robot-wrestling-rust-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Humanoid Robot Wrestling Controller Example

webots.cloud - Competition

Ferris Rust controller

Minimalist Rust controller example for the Humanoid Robot Wrestling Competition.

Demonstrates how to move the arm motor.

Uses the work-in-progress webots-rust bindings. Full access to the Webots libcontroller C API is provided through the webots::sys module, but ergonomic bindings are still work-in-progress and will be added as needed, with priority on the sensors and functionality offered by the NAO model used in the tournament.

use std::time::Duration;
use webots::prelude::*;

const MOVE_DELAY: Duration = Duration::from_millis(800);

struct Participant {
    move_timer: Duration,
    arm_up: bool,
    arm_motor: Motor,
}

impl Robot for Participant {
    fn init() -> Self {
        let arm_motor = Motor::new("RShoulderPitch");
        arm_motor.set_velocity(arm_motor.max_velocity());
        Participant {
            move_timer: Duration::ZERO,
            arm_motor,
            arm_up: false,
        }
    }

    fn step(&mut self, time: StepTime) {
        self.move_timer += time.delta;
        if self.move_timer > MOVE_DELAY {
            self.move_timer = Duration::ZERO;

            if !self.arm_up {
                self.arm_motor.set_position(self.arm_motor.max_position());
            } else {
                self.arm_motor.set_position(self.arm_motor.min_position());
            }
            self.arm_up = !self.arm_up;
        }
    }
}

fn main() {
    webots::run_robot::<Participant>();
}

Note that the controllers Dockerfile was also modified to include the installation of Rust.

About

Template for entering the ICRA 2023 Humanoid Robot Wrestling competition with a controller written in Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published