walter
Bot Class Reference

#include <bot.h>

Collaboration diagram for Bot:

Public Member Functions

 Bot ()
 
void execute ()
 Begins issuing instructions to the robot. More...
 
State get_state ()
 
void move_x (float distance, float velocity)
 Adds an instruction to move in the x direction. More...
 
void move_y (float distance, float velocity)
 Adds an instruction to move in the y direction. More...
 
void move (Eigen::Vector2f position, Eigen::Vector2f velocity)
 Adds an instruction to move. More...
 
void smooth_move (Eigen::Vector2f position, float velocity, float omega=1 *pi/3)
 Adds an instruction to move. More...
 
void spline_move ()
 
void rotate (float theta, float omega)
 Adds an instruction to rotate in place. More...
 
void set_led (std::vector< Eigen::Vector3i > lights)
 Messes with the lights on the robot, which the manual explicitly says not to do. More...
 
void set_pyr (Eigen::Vector3d pitch, Eigen::Vector3d yaw, Eigen::Vector3d roll)
 Sets pitch/yaw/roll of bot's body. More...
 
void set_height (float h, float v)
 Sets height of bot's body from the ground. More...
 

Private Member Functions

void UDPRecv ()
 Updates internal UDP struct. More...
 
void UDPSend ()
 Sends contents of internal UDP struct. More...
 
void RobotControl ()
 Executes each instruction. More...
 
Pose estimate_pose (Pose prev, a1::HighState state)
 Guesses current position. More...
 
bool validate_cmd (a1::HighCmd cmd)
 Ensures a HighCmd is safe to run. More...
 

Private Attributes

a1::Safety safe
 Specifies operation mode? More...
 
a1::UDP udp
 UDP struct that stores payloads to send/recv. More...
 
a1::HighCmd cmd = {0}
 Command to issue to robot's UDP server. More...
 
a1::HighState state = {0}
 State recieved from robot's UDP server. More...
 
Pose initial_pose
 Initial pose of current instruction. More...
 
int motiontime = 0
 Amount of time that has passed. More...
 
float dt = 0.002
 Timestep for threads. Allowed range: 0.001~0.01. More...
 
int index = 0
 Index of current instruction to execute. More...
 
bool executing = false
 Whether or not an instruction is in progress. More...
 
std::vector< Instructioninstructions
 List of Instructions to be executed sequentially by the A1. More...
 

Constructor & Destructor Documentation

◆ Bot()

Bot::Bot ( )
inline

Member Function Documentation

◆ estimate_pose()

Pose Bot::estimate_pose ( Pose  prev,
a1::HighState  state 
)
private

Guesses current position.

◆ execute()

void Bot::execute ( )

Begins issuing instructions to the robot.

Initializes the UDP threads and the control loop, then forces main thread to wait. Only call when all instructions have been specified.

◆ get_state()

State Bot::get_state ( )
Returns
state of the robot represented as a State.

◆ move()

void Bot::move ( Eigen::Vector2f  position,
Eigen::Vector2f  velocity 
)

Adds an instruction to move.

Parameters
positionPosition to walk to in meters relative to robot.
velocityVelocity of robot while walking. -0.4 to 0.4 m/s.

◆ move_x()

void Bot::move_x ( float  distance,
float  velocity 
)

Adds an instruction to move in the x direction.

Parameters
distanceRelative distance (in meters) to walk along x axis.
velocityVelocity of robot while walking. -0.7 to 1 m/s.

◆ move_y()

void Bot::move_y ( float  distance,
float  velocity 
)

Adds an instruction to move in the y direction.

Parameters
distanceRelative distance (in meters) to strafe along y axis.
velocityVelocity of robot while walking. -0.4 to 0.4 m/s.

◆ RobotControl()

void Bot::RobotControl ( )
private

Executes each instruction.

Ran repeatedly in a thread at runtime.

See also
Bot::execute()

◆ rotate()

void Bot::rotate ( float  theta,
float  omega 
)

Adds an instruction to rotate in place.

Parameters
thetaAngle to rotate (in rad).
omegaAngular velocity (in rad/s). -2pi/3 to 2pi/3 rad/s.

◆ set_height()

void Bot::set_height ( float  h,
float  v 
)

Sets height of bot's body from the ground.

Pretty useless for now.

◆ set_led()

void Bot::set_led ( std::vector< Eigen::Vector3i >  lights)

Messes with the lights on the robot, which the manual explicitly says not to do.

You probably shouldn't run this.

Parameters
lightsRGB values for each light.

◆ set_pyr()

void Bot::set_pyr ( Eigen::Vector3d  pitch,
Eigen::Vector3d  yaw,
Eigen::Vector3d  roll 
)

Sets pitch/yaw/roll of bot's body.

Pretty useless for now.

◆ smooth_move()

void Bot::smooth_move ( Eigen::Vector2f  position,
float  velocity,
float  omega = 1*pi/3 
)

Adds an instruction to move.

Rotates first, does no strafing.

Parameters
positionPosition to walk to in meters relative to robot.
velocityVelocity of robot while walking. -0.4 to 0.4 m/s.
omegaMagnitude of angular velocity (in rad/s). 0 to 2pi/3 rad/s.
See also
Bot::move()

◆ spline_move()

void Bot::spline_move ( )

◆ UDPRecv()

void Bot::UDPRecv ( )
private

Updates internal UDP struct.

Ran repeatedly in a thread at runtime.

See also
Bot::execute()

◆ UDPSend()

void Bot::UDPSend ( )
private

Sends contents of internal UDP struct.

Ran repeatedly in a thread at runtime.

See also
Bot::execute()

◆ validate_cmd()

bool Bot::validate_cmd ( a1::HighCmd  cmd)
private

Ensures a HighCmd is safe to run.

Member Data Documentation

◆ cmd

a1::HighCmd Bot::cmd = {0}
private

Command to issue to robot's UDP server.

◆ dt

float Bot::dt = 0.002
private

Timestep for threads. Allowed range: 0.001~0.01.

◆ executing

bool Bot::executing = false
private

Whether or not an instruction is in progress.

◆ index

int Bot::index = 0
private

Index of current instruction to execute.

◆ initial_pose

Pose Bot::initial_pose
private

Initial pose of current instruction.

See also
Bot::RobotControl

◆ instructions

std::vector<Instruction> Bot::instructions
private

List of Instructions to be executed sequentially by the A1.

See also
Bot::RobotControl()
Instruction

◆ motiontime

int Bot::motiontime = 0
private

Amount of time that has passed.

◆ safe

a1::Safety Bot::safe
private

Specifies operation mode?

◆ state

a1::HighState Bot::state = {0}
private

State recieved from robot's UDP server.

◆ udp

a1::UDP Bot::udp
private

UDP struct that stores payloads to send/recv.


The documentation for this class was generated from the following files: