Public Member Functions | Private Member Functions | Private Attributes
Nav2Remote Class Reference

Class for controlling Nav2 via turtle interface. More...

#include <nav2remote.h>

List of all members.

Public Member Functions

int back (double dist)
 Move backward.
int estimatePosition (double &x, double &y, double &orientation) const
 Estimate the position and orientation.
int forward (double dist)
 Move forward.
double getMaxAccel () const
 Get the maximum acceleration for turtle commands.
double getMaxCorneringError () const
 Get the maximum cornering error for turtle commands.
double getMaxSpeed () const
 Get the maximum speed for turtle commands.
int getQueueSize () const
 Get the turtle command queue size.
int move (double dist, double direction)
 Move in a specified direction.
 Nav2Remote (const char *host, int port=5010)
 Create the Nav2Remote object.
int setAbsoluteVelocity (double vx, double vy)
 Set the velocity in absolute coordinates.
int setMaxAccel (double maxAccel)
 Set the maximum acceleration for turtle commands.
int setMaxCorneringError (double error)
 Set the maximum cornering error for turtle commands.
int setMaxSpeed (double maxSpeed)
 Set the maximum speed for turtle commands.
int setPosition (double x, double y, double orientation)
 Set the current actual position and orientation.
int setRelativeVelocity (double vx, double vy, double turnRate=0.0)
 Set the relative velocity and turn rate.
int setTargetOrientation (double orientation)
 Set the target orientation in world coordinates.
int stop ()
 Stop the robot immediately.
int turnLeft (double angle)
 Turn left.
int turnRight (double angle)
 Turn right.
int wait () const
 Wait until the turtle command queue is empty.
 ~Nav2Remote ()

Private Member Functions

 Nav2Remote (const Nav2Remote &)
Nav2Remoteoperator= (const Nav2Remote &)
int readLine () const

Private Attributes

int fd
char * line
int lineLen

Detailed Description

Class for controlling Nav2 via turtle interface.

This class is a C++ front-end for Crosswing's serial turtle interface. This interface is not thread-safe. Most of these functions block on I/O.

Note that the turtle commands run asynchronously. Each command is added to the robot's path plan, and the function returns immediately. Call getQueueSize() to determine whether the robot has completed the requested path. Call wait() to wait until the queue is empty.

When this object goes out of scope (eg, when the program finishes), the robot will stop immediately, even if there are commands in the queue. Use wait() if you want to ensure that the path completes.

Definition at line 27 of file nav2remote.h.


Constructor & Destructor Documentation

Nav2Remote::Nav2Remote ( const Nav2Remote ) [private]
Nav2Remote::Nav2Remote ( const char *  host,
int  port = 5010 
)

Create the Nav2Remote object.

Constructs the object and connects to a remote turtle interface. If there is a connection problem, this function throws std::runtime_error.

Parameters:
hostThe remote hostname or IP address.
portThe TCP port.

Definition at line 18 of file nav2remote.cpp.

Definition at line 50 of file nav2remote.cpp.


Member Function Documentation

int Nav2Remote::back ( double  dist) [inline]

Move backward.

Queue a turtle command to move the robot backward by the specified distance. This is equivalent to move(-dist,0.0).

Parameters:
distThe distance in meters.
Returns:
0 on success, non-zero on IO error.

Definition at line 192 of file nav2remote.h.

int Nav2Remote::estimatePosition ( double &  x,
double &  y,
double &  orientation 
) const

Estimate the position and orientation.

Parameters:
xOutput parameter for the estimated x coordinate in meters.
yOutput parameter for the estimated y coordinate in meters.
orientationOutput parameter for the estimated orientation in radians.
Returns:
0 on success, non-zero on IO error.

Definition at line 106 of file nav2remote.cpp.

int Nav2Remote::forward ( double  dist) [inline]

Move forward.

Queue a turtle command to move the robot forward by the specified distance. This is equivalent to move(dist,0.0).

Parameters:
distThe distance in meters.
Returns:
0 on success, non-zero on IO error.

Definition at line 181 of file nav2remote.h.

double Nav2Remote::getMaxAccel ( ) const

Get the maximum acceleration for turtle commands.

Returns:
The maximum acceleration in meters per second squared, or -1 on IO error.
See also:
setMaxAccel

Definition at line 181 of file nav2remote.cpp.

Get the maximum cornering error for turtle commands.

Returns:
The maximum cornering error in meters, or -1 on IO error.
See also:
setMaxCorneringError

Definition at line 194 of file nav2remote.cpp.

double Nav2Remote::getMaxSpeed ( ) const

Get the maximum speed for turtle commands.

Returns:
The maximum speed in meters per second, or -1 on IO error.
See also:
setMaxSpeed

Definition at line 168 of file nav2remote.cpp.

int Nav2Remote::getQueueSize ( ) const

Get the turtle command queue size.

Get the number of turtle line segments remaining in the queue.

Returns:
The number of segments, or -1 on IO error.
See also:
wait

Definition at line 207 of file nav2remote.cpp.

int Nav2Remote::move ( double  dist,
double  direction 
)

Move in a specified direction.

Queue a turtle command to move a specified distance in the specified direction (relative to the robot's heading).

Parameters:
distThe distance in meters.
directionThe relative direction of travel in radians. Positive values are to the robot's left; Negative values are to the robot's right.
Returns:
0 on success, non-zero on IO error.

Definition at line 140 of file nav2remote.cpp.

Nav2Remote& Nav2Remote::operator= ( const Nav2Remote ) [private]
int Nav2Remote::readLine ( ) const [private]

Definition at line 56 of file nav2remote.cpp.

int Nav2Remote::setAbsoluteVelocity ( double  vx,
double  vy 
)

Set the velocity in absolute coordinates.

Set the robot's velocity in absolute coordinates. This function overrides and clears the turtle command queue.

Parameters:
vxThe x-component of the velocity in meters per second.
vyThe y-component of the velocity in meters per second.
Returns:
0 on success, non-zero on IO error.
See also:
setRelativeVelocity, estimatePosition

Definition at line 92 of file nav2remote.cpp.

int Nav2Remote::setMaxAccel ( double  maxAccel)

Set the maximum acceleration for turtle commands.

This does not affect the behaviour of setTargetVelocity().

Parameters:
maxAccelThe maximum acceleration in meters per second squared.
Returns:
0 on success, non-zero on IO error.
See also:
getMaxAccel

Definition at line 154 of file nav2remote.cpp.

int Nav2Remote::setMaxCorneringError ( double  error)

Set the maximum cornering error for turtle commands.

When following turtle commands, the robot will plan to come at least that near to each corner in the resulting path. If this value is set to 0, the robot will come to a complete stop at each corner. Setting this to larger values allows the robot to follow the path at a higher speed.

Parameters:
errorThe maximum cornering error in meters.
Returns:
0 on success, non-zero on IO error.
See also:
getMaxCorneringError

Definition at line 161 of file nav2remote.cpp.

int Nav2Remote::setMaxSpeed ( double  maxSpeed)

Set the maximum speed for turtle commands.

This does not affect the behaviour of setTargetVelocity().

Parameters:
maxSpeedThe maximum speed in meters per second.
Returns:
0 on success, non-zero on IO error.
See also:
getMaxSpeed

Definition at line 147 of file nav2remote.cpp.

int Nav2Remote::setPosition ( double  x,
double  y,
double  orientation 
)

Set the current actual position and orientation.

The provided values will be used as ground truth for future estimates.

Parameters:
xThe absolute x coordinate in meters.
yThe absolute y coordinate in meters.
orientationThe absolute orientation in radians.
Returns:
0 on success, non-zero on IO error.

Definition at line 121 of file nav2remote.cpp.

int Nav2Remote::setRelativeVelocity ( double  vx,
double  vy,
double  turnRate = 0.0 
)

Set the relative velocity and turn rate.

Set the robot's velocity relative to its own orientation, and the rate of rotation. If the velocity and turn rate are both non-zero, the robot will follow a circular path. A velocity of zero with a non-zero turn rate will cause the robot to rotate in place. This function overrides and clears the turtle command queue.

Examples:
setRelativeVelocity(0.3,0.0,0.0) - Move straight forward.
setRelativeVelocity(0.0,0.3,0.0) - Move leftward.
setRelativeVelocity(0.0,-0.2,-1.5) - Move rightward, while rotating clockwise.

Parameters:
vxThe x-component of the velocity in meters per second.
vyThe y-component of the velocity in meters per second.
turnRateThe turn rate in radians per second. Use positive values for counterclockwise rotation, or negative values for clockwise rotation.
Returns:
0 on success, non-zero on IO error.
See also:
setAbsoluteVelocity

Definition at line 99 of file nav2remote.cpp.

int Nav2Remote::setTargetOrientation ( double  orientation)

Set the target orientation in world coordinates.

At an orientation of zero, the robot is facing in the direction of the positive x axis. If the robot needs to rotate, its rotational speed will gradually increase then gradually decrease to try to achieve the given orientation.

Parameters:
orientationthe target orientation in radians.
Returns:
0 on success, non-zero on IO error.

Definition at line 85 of file nav2remote.cpp.

Stop the robot immediately.

Returns:
0 on success, non-zero on IO error.

Definition at line 128 of file nav2remote.cpp.

int Nav2Remote::turnLeft ( double  angle)

Turn left.

Queue a turtle command to turn left by the specified angle.

Parameters:
angleThe angle in radians.
Returns:
0 on success, non-zero on IO error.

Definition at line 133 of file nav2remote.cpp.

int Nav2Remote::turnRight ( double  angle) [inline]

Turn right.

Queue a turtle command to turn right by the specified angle.

Parameters:
angleThe angle in radians.
Returns:
0 on success, non-zero on IO error.

Definition at line 156 of file nav2remote.h.

int Nav2Remote::wait ( ) const

Wait until the turtle command queue is empty.

Returns:
0 on success, or -1 on IO error.
See also:
getQueueSize

Definition at line 221 of file nav2remote.cpp.


Member Data Documentation

int Nav2Remote::fd [private]

Definition at line 35 of file nav2remote.h.

char* Nav2Remote::line [mutable, private]

Definition at line 33 of file nav2remote.h.

int Nav2Remote::lineLen [mutable, private]

Definition at line 34 of file nav2remote.h.


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


nav2_driver
Author(s): Paul Bovbel
autogenerated on Fri Aug 28 2015 11:45:16