pub struct DriverStation { /* private fields */ }Expand description
Represents a connection to the roboRIO acting as a driver station
This struct will contain relevant functions to update the state of the robot, and also manages the threads that manage network connections and joysticks
Implementations§
Source§impl DriverStation
impl DriverStation
Sourcepub fn new_team(team_number: u32, alliance: Alliance) -> DriverStation
pub fn new_team(team_number: u32, alliance: Alliance) -> DriverStation
Creates a new driver station with the given team number and alliance
This driver station will attempt to connect to a roboRIO at 10.TE.AM.2, if the roboRIO is at a different ip, use [new] and specify the ip directly.
Sourcepub fn new(ip: &str, alliance: Alliance, team_number: u32) -> DriverStation
pub fn new(ip: &str, alliance: Alliance, team_number: u32) -> DriverStation
Creates a new driver station for the given alliance station and team number
Connects to the roborio at ip. To infer the ip from team_number, use new_team instead.
Sourcepub fn set_joystick_supplier(
&mut self,
supplier: impl Fn() -> Vec<Vec<JoystickValue>> + Send + Sync + 'static,
)
pub fn set_joystick_supplier( &mut self, supplier: impl Fn() -> Vec<Vec<JoystickValue>> + Send + Sync + 'static, )
Provides a closure that will be called when constructing outbound packets to append joystick values
Sourcepub fn set_tcp_consumer(
&mut self,
consumer: impl FnMut(TcpPacket) + Send + Sync + 'static,
)
pub fn set_tcp_consumer( &mut self, consumer: impl FnMut(TcpPacket) + Send + Sync + 'static, )
Provides a closure that will be called when TCP packets are received from the roboRIO
Example usage: Logging all stdout messages from robot code.
Sourcepub fn set_alliance(&mut self, alliance: Alliance)
pub fn set_alliance(&mut self, alliance: Alliance)
Changes the alliance for the given DriverStation
pub fn ds_mode(&self) -> DsMode
Sourcepub fn set_team_number(&mut self, team_number: u32)
pub fn set_team_number(&mut self, team_number: u32)
Changes the team number of this driver station, as well as the ip the driver station will attempt to connect to. The ip of the new roboRIO target is 10.TE.AM.2
pub fn set_use_usb(&mut self, use_usb: bool)
pub fn team_number(&self) -> u32
Sourcepub fn set_game_specific_message(&mut self, message: &str) -> Result<()>
pub fn set_game_specific_message(&mut self, message: &str) -> Result<()>
Sets the game specific message sent to the robot, and used during the autonomous period
Sourcepub fn restart_code(&mut self)
pub fn restart_code(&mut self)
Instructs the roboRIO to restart robot code
Sourcepub fn restart_roborio(&mut self)
pub fn restart_roborio(&mut self)
Instructs the roboRIO to reboot
Sourcepub fn battery_voltage(&self) -> f32
pub fn battery_voltage(&self) -> f32
Returns the last received battery voltage from the robot
Sourcepub fn queue_udp(&mut self, udp_tag: UdpTag)
pub fn queue_udp(&mut self, udp_tag: UdpTag)
Queues a UDP tag to be transmitted with the next outbound packet to the roboRIO