GT RoboCup SSL
Soccer software, robot firmware
OurRobot Class Reference

A robot on our team. More...

Public Types

typedef std::array< float, Num_Shells > RobotMask
 

Public Member Functions

 OurRobot (int shell, Context *const context)
 Construct a new OurRobot. More...
 
void addStatusText ()
 
void addText (const QString &text, const QColor &color=Qt::white, const QString &layerPrefix="RobotText")
 
bool charged () const
 true if the kicker is ready
 
float kickTimer () const
 returns the time since the kicker was last charged, 0.0 if ready
 
const Geometry2d::Segment kickerBar () const
 segment for the location of the kicker
 
Geometry2d::Point pointInRobotSpace (Geometry2d::Point pt) const
 converts a point to the frame of reference of robot
 
bool behindBall (Geometry2d::Point ballPos) const
 returns true if the position specified is behind the robot
 
std::optional< Eigen::Quaternionf > quaternion () const
 
const RobotConstraintsrobotConstraints () const
 
RobotConstraintsrobotConstraints ()
 
const MotionConstraintsmotionConstraints () const
 
MotionConstraintsmotionConstraints ()
 
const Planning::RotationCommandrotationCommand () const
 
const Planning::Pathpath ()
 Returns a const reference to the path of the robot.
 
void resetForNextIteration ()
 clears old radioTx stuff, resets robot debug text, and clears local obstacles
 
void resetMotionConstraints ()
 clears all fields in the robot's MotionConstraints object, causing the robot to stop
 
void stop ()
 Stop the robot.
 
void lineKick (Geometry2d::Point target)
 Makes this robot execute a lineKick. More...
 
void intercept (Geometry2d::Point target)
 Intercept the ball as quickly as possible May just slam into the ball if it does not have time to stop. More...
 
void move (Geometry2d::Point goal, Geometry2d::Point endVelocity=Geometry2d::Point())
 Move to a given point using the default RRT planner. More...
 
void moveDirect (Geometry2d::Point goal, float endSpeed=0)
 Move to a given point bypassing the RRT Path planner. More...
 
void moveTuning (Geometry2d::Point goal, float endSpeed=0)
 Move to a given point while breaking everything. More...
 
void settle (std::optional< Geometry2d::Point > target)
 Move in front of the ball to intercept it. More...
 
void collect ()
 Approaches the ball and moves through it slowly.
 
void worldVelocity (Geometry2d::Point targetWorldVel)
 Sets the worldVelocity in the robot's MotionConstraints.
 
void face (Geometry2d::Point pt)
 Face a point while remaining in place.
 
bool isFacing ()
 Returns true if the robot currently has a face command.
 
void faceNone ()
 Remove the facing command.
 
void pivot (Geometry2d::Point pivotTarget)
 The robot pivots around it's mouth toward the given target.
 
void dribble (uint8_t speed)
 
void kick (float strength)
 KICKING/CHIPPING. More...
 
void kickLevel (uint8_t strength)
 enable kick when ready at a given strength (0-255)
 
void chip (float strength)
 enable chip when ready at a given percentage of the currently set max chip power. More...
 
void chipLevel (uint8_t strength)
 enable chip when ready at a given strength (0-255)
 
void unkick ()
 Undoes any calls to kick() or chip().
 
RJ::Timestamp lastKickTime () const
 
bool justKicked ()
 checks if the bot has kicked/chipped very recently.
 
std::string getCmdText () const
 Gets a string representing the series of commands called on the robot this iteration. More...
 
void kickImmediately ()
 ignore ball sense and kick immediately
 
bool avoidOpponents () const
 
void avoidOpponents (bool enable)
 
void disableAvoidBall ()
 
void avoidBallRadius (float radius)
 
float avoidBallRadius () const
 
void resetAvoidBall ()
 
void resetAvoidRobotRadii ()
 
void localObstacles (const std::shared_ptr< Geometry2d::Shape > &obs)
 Adds an obstacle to the local set of obstacles for avoidance Cleared after every frame.
 
const Geometry2d::ShapeSetlocalObstacles () const
 
void clearLocalObstacles ()
 
std::vector< Planning::DynamicObstaclecollectDynamicObstacles ()
 
Geometry2d::ShapeSet collectStaticObstacles (const Geometry2d::ShapeSet &globalObstacles, bool localObstacles=true)
 
Geometry2d::ShapeSet collectAllObstacles (const Geometry2d::ShapeSet &globalObstacles)
 
void approachAllOpponents (bool enable=true)
 
void avoidAllOpponents (bool enable=true)
 
bool avoidOpponent (unsigned shell_id) const
 checks if opponents are avoided at all
 
bool approachOpponent (unsigned shell_id) const
 
float avoidOpponentRadius (unsigned shell_id) const
 returns the avoidance radius
 
void avoidAllOpponentRadius (float radius)
 returns the avoidance radius
 
void avoidOpponent (unsigned shell_id, bool enable_avoid)
 enable/disable for opponent avoidance
 
void approachOpponent (unsigned shell_id, bool enable_approach)
 enable/disable approach of opponents - diable uses larger avoidance radius
 
void avoidOpponentRadius (unsigned shell_id, float radius)
 
Geometry2d::Point mouthCenterPos () const
 
bool chipper_available () const
 status evaluations for choosing robots in behaviors - combines multiple checks
 
bool kicker_available () const
 
bool dribbler_available () const
 
bool driving_available (bool require_all=true) const
 
bool hasBall () const
 
bool hasBallRaw () const
 
bool ballSenseWorks () const
 
bool kickerWorks () const
 
float kickerVoltage () const
 
Packet::HardwareVersion hardwareVersion () const
 
void setRadioRx (Packet::RadioRx packet)
 
Packet::RadioRx radioRx () const
 
const std::unique_ptr< Planning::MotionCommand > & motionCommand () const
 
const RotationConstraintsrotationConstraints () const
 
RotationConstraintsrotationConstraints ()
 
MotionControlmotionControl () const
 
SystemStatestate () const
 
bool rxIsFresh (RJ::Seconds age=RJ::Seconds(0.5)) const
 
void sing (Packet::Control::Song song=Packet::Control::FIGHT_SONG)
 start the robot playing a song More...
 
double distanceToChipLanding (int chipPower)
 
uint8_t chipPowerForDistance (double distance)
 
void setPath (std::unique_ptr< Planning::Path > path)
 
void setPlanningPriority (int8_t priority)
 Sets the priority which paths are planned. More...
 
int8_t getPlanningPriority ()
 Gets the priority which paths are planned. More...
 
void setPID (double p, double i, double d)
 
- Public Member Functions inherited from Robot
 Robot (unsigned int shell, bool self)
 
unsigned int shell () const
 ID number for the robot. More...
 
bool self () const
 Check whether or not this robot is on our team.
 
bool operator== (const Robot &other)
 
std::string toString () const
 

Static Public Member Functions

static void createConfiguration (Configuration *cfg)
 

Public Attributes

Packet::Robot robotPacket
 radio packets
 
Packet::Control * control
 
RobotConfigconfig
 
RobotStatusstatus
 
boost::ptr_vector< Packet::DebugText > robotText
 
bool isPenaltyKicker = false
 
bool isBallPlacer = false
 
- Public Attributes inherited from RobotPose
bool visible
 
bool velValid
 
Geometry2d::Point pos
 
Geometry2d::Point vel
 
double angle
 angle in radians. 0 radians means the robot is aimed along the x-axis
 
double angleVel
 
RJ::Time time
 angular velocity in radians/sec
 

Protected Member Functions

template<class ROBOT >
Geometry2d::ShapeSet createRobotObstacles (const std::vector< ROBOT *> &robots, const RobotMask &mask) const
 latest path More...
 
template<class ROBOT >
Geometry2d::ShapeSet createRobotObstacles (const std::vector< ROBOT *> &robots, const RobotMask &mask, Geometry2d::Point currentPosition, float checkRadius) const
 Only adds obstacles within the checkRadius of the passed in position Creates a set of obstacles from a given robot team mask, where mask values < 0 create no obstacle, and larger values create an obstacle of a given radius. More...
 
std::shared_ptr< Geometry2d::CirclecreateBallObstacle () const
 Creates an obstacle for the ball if necessary.
 
void radioRxUpdated ()
 The processor mutates RadioRx in place and calls this afterwards to let it know that it changed.
 

Protected Attributes

MotionControl_motionControl
 
Context *const _context
 
Geometry2d::ShapeSet _local_obstacles
 set of obstacles added by plays
 
RobotMask _opp_avoid_mask
 masks for obstacle avoidance
 
float _avoidBallRadius
 
std::unique_ptr< Planning::MotionCommand_motionCommand
 radius of ball obstacle
 
std::unique_ptr< Planning::RotationCommand_rotationCommand
 
RobotConstraints _robotConstraints
 
Planning::AngleFunctionPath angleFunctionPath
 

Friends

class Processor
 
class MotionControl
 

Detailed Description

A robot on our team.

This extends Robot and provides methods for interacting with our robots. A few things this class is responsible for:

  • specifying target position, velocity, angle, etc
  • kicking and chipping the ball
  • keeping track of which hardware revision this bot is
  • avoidance of the ball and other robots (this info is fed to the path planner)
  • playing the GT fight song
+ Inheritance diagram for OurRobot:
+ Collaboration diagram for OurRobot:

Constructor & Destructor Documentation

◆ OurRobot()

OurRobot::OurRobot ( int  shell,
Context *const  context 
)

Construct a new OurRobot.

Parameters
shellThe robot ID
stateA pointer to the global system state object

Member Function Documentation

◆ approachOpponent()

bool OurRobot::approachOpponent ( unsigned  shell_id) const
Returns
true if we are able to approach the given opponent

◆ chip()

void OurRobot::chip ( float  strength)

enable chip when ready at a given percentage of the currently set max chip power.

Parameters
strengtha value between 0 and 1

◆ createRobotObstacles() [1/2]

template<class ROBOT >
Geometry2d::ShapeSet OurRobot::createRobotObstacles ( const std::vector< ROBOT *> &  robots,
const RobotMask &  mask 
) const
inlineprotected

latest path

Creates a set of obstacles from a given robot team mask, where mask values < 0 create no obstacle, and larger values create an obstacle of a given radius

NOTE: mask must not be set for this robot

Parameters
robotsis the set of robots to use to create a mask - either self or opp from _state

◆ createRobotObstacles() [2/2]

template<class ROBOT >
Geometry2d::ShapeSet OurRobot::createRobotObstacles ( const std::vector< ROBOT *> &  robots,
const RobotMask &  mask,
Geometry2d::Point  currentPosition,
float  checkRadius 
) const
inlineprotected

Only adds obstacles within the checkRadius of the passed in position Creates a set of obstacles from a given robot team mask, where mask values < 0 create no obstacle, and larger values create an obstacle of a given radius.

NOTE: mask must not be set for this robot

Parameters
robotsis the set of robots to use to create a mask - either self or opp from _state

◆ getCmdText()

std::string OurRobot::getCmdText ( ) const

Gets a string representing the series of commands called on the robot this iteration.

Contains face(), move(), etc - used to display in the BehaviorTree tab in soccer

◆ getPlanningPriority()

int8_t OurRobot::getPlanningPriority ( )
inline

Gets the priority which paths are planned.

Higher priority values are planned first.

◆ intercept()

void OurRobot::intercept ( Geometry2d::Point  target)

Intercept the ball as quickly as possible May just slam into the ball if it does not have time to stop.

Parameters
target- The target position to intercept the ball at

◆ kick()

void OurRobot::kick ( float  strength)

KICKING/CHIPPING.

When we call kick() or chip(), it doesn't happen immediately. It primes the kicker or chipper to kick at the designated power the next time the bot senses that it has the ball. Once this happens, we record the time of the actual kick. enable kick when ready at a given percentage of the currently set max kick power.

Parameters
strengtha value between 0 and 1

◆ lineKick()

void OurRobot::lineKick ( Geometry2d::Point  target)

Makes this robot execute a lineKick.

Parameters
target- The target to kick towards (aiming point)

◆ move()

void OurRobot::move ( Geometry2d::Point  goal,
Geometry2d::Point  endVelocity = Geometry2d::Point() 
)

Move to a given point using the default RRT planner.

Parameters
endSpeed- the speed we should be going when we reach the end of the path

◆ moveDirect()

void OurRobot::moveDirect ( Geometry2d::Point  goal,
float  endSpeed = 0 
)

Move to a given point bypassing the RRT Path planner.

This will plan a direct path ignoring all obstacles and the starting velocity

Parameters
endSpeed- the speed we should be going when we reach the end of the path

◆ moveTuning()

void OurRobot::moveTuning ( Geometry2d::Point  goal,
float  endSpeed = 0 
)

Move to a given point while breaking everything.

Tells the robot it is already at the endpoint

Parameters
endSpeed- the speed we should be going when we reach the end of the path. I'm not even sure if this part makes any sense here.

◆ rxIsFresh()

bool OurRobot::rxIsFresh ( RJ::Seconds  age = RJ::Seconds(0.5)) const
Parameters
ageTime (in microseconds) that defines non-fresh

◆ setPlanningPriority()

void OurRobot::setPlanningPriority ( int8_t  priority)
inline

Sets the priority which paths are planned.

Higher priority values are planned first.

◆ settle()

void OurRobot::settle ( std::optional< Geometry2d::Point target)

Move in front of the ball to intercept it.

If a target face point is given, the robot will try to face in that direction when the ball hits

Parameters
target- the target point in which the robot will try to bounce the towards

◆ sing()

void OurRobot::sing ( Packet::Control::Song  song = Packet::Control::FIGHT_SONG)
inline

start the robot playing a song

Parameters
song

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