Roomba Controller Dashboard 1
A GUI and TCP client application that is used to control a Roomba for Computer Engineering 2880 @ Iowa State
Loading...
Searching...
No Matches
Pose2D Class Reference

#include <Pose2D.hpp>

Public Member Functions

 Pose2D (double x, double y, double heading)
 
 Pose2D (double x, double y)
 
 Pose2D ()
 
 Pose2D (const Pose2D &position)
 
double angleTo (const Pose2D &other) const
 
double distanceTo (const Pose2D &other) const
 
double squareOfDistanceTo (const Pose2D &other) const
 
Pose2D clone () const
 
void rotateByPose (const Pose2D &rotation)
 
void rotateByAngle (double angle)
 
void translateByPose (const Pose2D &translation)
 
void translateByMagnitude (double magnitude)
 
void transformPose (const Pose2D &modifier)
 
double getX () const
 
double getY () const
 
double getHeading () const
 
void setHeading (double angle)
 
void plusCoord (const Pose2D &other)
 
void plus (const Pose2D &other)
 
void minus (Pose2D other)
 
void addAngle (double angle)
 
Pose2D subtractBy (const Pose2D &other) const
 
Pose2D scaleBy (double scaler) const
 
Pose2D normalize () const
 
double dotProduct (const Pose2D &other) const
 
void setX (double x)
 
void vecAdd (double angle, double magnitude)
 
void setY (double y)
 
uint8_t getQuadrant () const
 
void wrapHeading ()
 
void transformForPose (const Pose2D &other)
 
bool isOnLine (Pose2D LineEnd1, Pose2D LineEnd2)
 
bool isPerpendicularToLine (double m)
 
void multiply (double d)
 

Static Public Member Functions

static Pose2D fromPolar (double magnitude, double angle)
 
static double degreesToRadians (double degrees)
 
static double radiansToDegrees (double radians)
 
static Pose2D parseFromStream (std::istringstream &stream)
 
static double getAngleBetweenPoints (Pose2D corner, Pose2D end1, Pose2D end2)
 

Protected Attributes

double x
 
double y
 
double heading
 

Friends

std::ostream & operator<< (std::ostream &os, const Pose2D &d)
 

Detailed Description

A class representing a 2D position and a heading. Implements common vector functions

Definition at line 23 of file Pose2D.hpp.

Constructor & Destructor Documentation

◆ Pose2D() [1/4]

Pose2D::Pose2D ( double x,
double y,
double heading )

Consctructs a new Pose2D object

Parameters
xthe x component
ythe y component
headingthe heading

Definition at line 7 of file Pose2D.cpp.

◆ Pose2D() [2/4]

Pose2D::Pose2D ( double x,
double y )

Constructs a new Pose2D object

Parameters
xcomponent
ycomponent

Definition at line 13 of file Pose2D.cpp.

◆ Pose2D() [3/4]

Pose2D::Pose2D ( )

Makes a new Pose2D with 0's as default

Definition at line 18 of file Pose2D.cpp.

◆ Pose2D() [4/4]

Pose2D::Pose2D ( const Pose2D & position)

Constructs a new Pose2D. Copy constructor.

Parameters
positionthe pose to copy

Definition at line 64 of file Pose2D.cpp.

Member Function Documentation

◆ addAngle()

void Pose2D::addAngle ( double angle)

Add the angle to heading

Parameters
anglegets added to "this" heading

Definition at line 82 of file Pose2D.cpp.

◆ angleTo()

double Pose2D::angleTo ( const Pose2D & other) const

Calculates the angle from one node to another

Parameters
otherangle to get to
Returns
the angle between two nodes

Definition at line 78 of file Pose2D.cpp.

◆ clone()

Pose2D Pose2D::clone ( ) const

Makes a copy of this node

Returns
the copy of this node

Definition at line 106 of file Pose2D.cpp.

◆ degreesToRadians()

double Pose2D::degreesToRadians ( double degrees)
static

Calculates the radian equivalent of degrees

Parameters
degreesthe angle in degrees
Returns
the angle in radians

Definition at line 200 of file Pose2D.cpp.

◆ distanceTo()

double Pose2D::distanceTo ( const Pose2D & other) const

Calculates the distance between two nodes

Parameters
otherthe other node to calculate the distance to
Returns
the distance between the two nodes

Definition at line 86 of file Pose2D.cpp.

◆ dotProduct()

double Pose2D::dotProduct ( const Pose2D & other) const

Calculate the dot product from the nodes: "this" and other

Parameters
otherother node to calculate the dot product with
Returns
a double resembling the dot product

Definition at line 226 of file Pose2D.cpp.

◆ fromPolar()

Pose2D Pose2D::fromPolar ( double magnitude,
double angle )
static

Creates a new Pose2D from polar coordinats

Parameters
magnitudethe magnitude of the position
anglethe angle of the position
Returns
A Pose2D object representing the polar coordinates

Definition at line 193 of file Pose2D.cpp.

◆ getAngleBetweenPoints()

static double Pose2D::getAngleBetweenPoints ( Pose2D corner,
Pose2D end1,
Pose2D end2 )
static

gets the angle between points in radians.

Parameters
corner
end1
end2
Returns
the angle between all of these points

◆ getHeading()

double Pose2D::getHeading ( ) const

get the heading of the position

Returns
the heading of the bot

Definition at line 155 of file Pose2D.cpp.

◆ getQuadrant()

uint8_t Pose2D::getQuadrant ( ) const

Gets the quadrant that a Pose is in. If the pose is on the origin or on an intercept it return's 0. otherwise going from pos pos (1) it travels counter clockwise around in a circle

Returns
(0, 0): 0 (+, +): 1 (-, +): 2 (-, -): 3 (+, -): 4

Definition at line 171 of file Pose2D.cpp.

◆ getX()

double Pose2D::getX ( ) const

get the x component of the position

Returns
the c component

Definition at line 147 of file Pose2D.cpp.

◆ getY()

double Pose2D::getY ( ) const

gets the y component of the position

Returns
the y component

Definition at line 151 of file Pose2D.cpp.

◆ isOnLine()

bool Pose2D::isOnLine ( Pose2D LineEnd1,
Pose2D LineEnd2 )

Makes a slope intercept object from two pose2Ds

Parameters
onethe first position
twothe second position
Returns
Slope intercept object that runs through two points Determines whether a pose is on a given bounded line
Parameters
LineEnd1one endpoint of the line
LineEnd2the other endpoint of the line

Definition at line 24 of file Pose2D.cpp.

◆ isPerpendicularToLine()

bool Pose2D::isPerpendicularToLine ( double m)

Determines whether a position is perpendicular to a given line

◆ minus()

void Pose2D::minus ( Pose2D other)

Subtract this by other. Subtracts the components

Parameters
otherthe other node to subtract by

Definition at line 187 of file Pose2D.cpp.

◆ multiply()

void Pose2D::multiply ( double d)

Multiplys the x and y components by a scalar

Definition at line 267 of file Pose2D.cpp.

◆ normalize()

Pose2D Pose2D::normalize ( ) const

Normalizes a position to a unit vector

Returns
a unit vector representing this position

Definition at line 221 of file Pose2D.cpp.

◆ parseFromStream()

Pose2D Pose2D::parseFromStream ( std::istringstream & stream)
static

Parse a pose 2d from a string stream

Parameters
streamthe stream to parse from
Returns
a pose2D from the data in the stream

Definition at line 204 of file Pose2D.cpp.

◆ plus()

void Pose2D::plus ( const Pose2D & other)

Computes a vector addition. Adds components of vectors together

Parameters
otherthe other pose

Definition at line 100 of file Pose2D.cpp.

◆ plusCoord()

void Pose2D::plusCoord ( const Pose2D & other)

Sum of two coordinates

Parameters
otherthe node to add

Definition at line 123 of file Pose2D.cpp.

◆ radiansToDegrees()

static double Pose2D::radiansToDegrees ( double radians)
static

Calculates the degree equivalent of radians

Parameters
radiansthe angle in radians
Returns
the angle in degrees

◆ rotateByAngle()

void Pose2D::rotateByAngle ( double angle)

Uses a rotation matrix to rotate a Pose2D by an angle. Rotates about the origin.

Parameters
angleto rotate by.

Definition at line 116 of file Pose2D.cpp.

◆ rotateByPose()

void Pose2D::rotateByPose ( const Pose2D & rotation)

Rotate a Pose2D by the a rotation cooresponding to the heading of the other pose

Parameters
rotationthe pose to rotate by

Definition at line 128 of file Pose2D.cpp.

◆ scaleBy()

Pose2D Pose2D::scaleBy ( double scaler) const

Scales a position by another. Returs result

Parameters
scaleramount to scale this vector as a pose by
Returns
the result of the scaling operation

Definition at line 217 of file Pose2D.cpp.

◆ setHeading()

void Pose2D::setHeading ( double angle)

Sets the heading of the Pose

Parameters
anglethe angle to set the Pose at

Definition at line 159 of file Pose2D.cpp.

◆ setX()

void Pose2D::setX ( double x)

Setter for x

Parameters
xthe new x value

Definition at line 163 of file Pose2D.cpp.

◆ setY()

void Pose2D::setY ( double y)

Setter for y

Parameters
ythe new y value

Definition at line 167 of file Pose2D.cpp.

◆ squareOfDistanceTo()

double Pose2D::squareOfDistanceTo ( const Pose2D & other) const

calculate the squared distance to another object

Parameters
otherthe object to get the squared distance to
Returns
the squared distance to the other object

Definition at line 90 of file Pose2D.cpp.

◆ subtractBy()

Pose2D Pose2D::subtractBy ( const Pose2D & other) const

Subtract "this" from other by components and return the result

Parameters
otherthe other node to subtract by
Returns
the result of the subtraction

Definition at line 213 of file Pose2D.cpp.

◆ transformForPose()

void Pose2D::transformForPose ( const Pose2D & other)

transforms a given pose for another's frame

Parameters
otherthe other frame

Definition at line 94 of file Pose2D.cpp.

◆ transformPose()

void Pose2D::transformPose ( const Pose2D & modifier)

transform a position with a rotation and a translation

Parameters
modifierthe heading gets used as the rotation. The compoenent get used as the translation

Definition at line 142 of file Pose2D.cpp.

◆ translateByMagnitude()

void Pose2D::translateByMagnitude ( double magnitude)

This is admitedly a bit of a goofy function. We take the magnitude of the translation and extend the current position by that much in the heading of the pose. I like to think of the Pose2D as a vector, then we take the heading and combine it into a pollar coordinate with the magnitude. Then we do vector addition on the Pose2D.

Parameters
magnitudeto extend by

Definition at line 137 of file Pose2D.cpp.

◆ translateByPose()

void Pose2D::translateByPose ( const Pose2D & translation)

Translation for a pose by another pose. Vector addition

Parameters
translationthe pose to add

Definition at line 132 of file Pose2D.cpp.

◆ vecAdd()

void Pose2D::vecAdd ( double angle,
double magnitude )

Computes a vector addition from an angle and quantity

Parameters
anglethe angle component of the vector
magnitudethe quantity component of the vector

Definition at line 110 of file Pose2D.cpp.

◆ wrapHeading()

void Pose2D::wrapHeading ( )

Wraps a heading to - PI -> PI

Definition at line 235 of file Pose2D.cpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Pose2D & d )
friend

To string for a pose2D

Parameters
osoutput stream
dthe pose2D to reference
Returns

Definition at line 230 of file Pose2D.cpp.

Member Data Documentation

◆ heading

double Pose2D::heading
protected

Definition at line 25 of file Pose2D.hpp.

◆ x

double Pose2D::x
protected

Definition at line 25 of file Pose2D.hpp.

◆ y

double Pose2D::y
protected

Definition at line 25 of file Pose2D.hpp.


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