utility.h
/*
* Player - One Hell of a Robot Server
* Copyright (C) 2000-2003
* Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/********************************************************************
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
********************************************************************/
/***************************************************************************
* Desc: Player v2.0 C++ client
* Authors: Brad Kratochvil, Toby Collett
*
* Date: 23 Sep 2005
# CVS: $Id: utility.h 7342 2009-02-18 03:43:36Z gbiggs $
**************************************************************************/
#ifndef PLAYERCC_UTILITY_H
#define PLAYERCC_UTILITY_H
namespace PlayerCc
{
const int PLAYER_PORTNUM = 6665;
const std::string PLAYER_HOSTNAME = "localhost";
// Since they are inline, these functions are as efficient as DEFINES,
// but now they have the benefit of type checking!
inline double rtod(double r)
{
return r * 180.0 / M_PI;
}
inline double dtor(double r)
{
return r * M_PI / 180.0;
}
inline double normalize(double z)
{
return atan2(sin(z), cos(z));
}
#if defined (min)
#undef min
#endif
template<typename T>
inline T min(T a, T b)
{
if (a < b)
return a;
else
return b;
}
#if defined (max)
#undef max
#endif
template<typename T>
inline T max(T a, T b)
{
if (a > b)
return a;
else
return b;
}
template<typename T>
inline T limit(T a, T min, T max)
{
if (a < min)
return min;
else if (a > max)
return max;
else
return a;
}
} // namespace
#endif
PlayerCc::PLAYER_HOSTNAME
const std::string PLAYER_HOSTNAME
The default hostname for PlayerClient.
Definition: utility.h:63
PlayerCc::limit
T limit(T a, T min, T max)
Limit a value to the range of min, max.
Definition: utility.h:114
PlayerCc::PLAYER_PORTNUM
const int PLAYER_PORTNUM
The default port number for PlayerClient.
Definition: utility.h:61
PlayerCc::dtor
double dtor(double r)
Convert degrees to radians.
Definition: utility.h:75
PlayerCc::normalize
double normalize(double z)
Normalize angle to domain -pi, pi.
Definition: utility.h:81
PlayerCc::max
T max(T a, T b)
Return the maximum of a, b.
Definition: utility.h:104
PlayerCc::min
T min(T a, T b)
Return the minimum of a, b.
Definition: utility.h:91
PlayerCc::rtod
double rtod(double r)
Convert radians to degrees.
Definition: utility.h:69

Last updated 12 September 2005 21:38:45