00001 /* 00002 COPYRIGHT (c) 2014 SEGWAY Inc. 00003 00004 Software License Agreement: 00005 00006 The software supplied herewith by Segway Inc. (the "Company") for its 00007 RMP Robotic Platforms is intended and supplied to you, the Company's 00008 customer, for use solely and exclusively with Segway products. The 00009 software is owned by the Company and/or its supplier, and is protected 00010 under applicable copyright laws. All rights are reserved. Any use in 00011 violation of the foregoing restrictions may subject the user to criminal 00012 sanctions under applicable laws, as well as to civil liability for the 00013 breach of the terms and conditions of this license. The Company may 00014 immediately terminate this Agreement upon your use of the software with 00015 any products that are not Segway products. 00016 00017 You shall indemnify, defend and hold the Company harmless from any claims, 00018 demands, liabilities or expenses, including reasonable attorneys fees, incurred 00019 by the Company as a result of any claim or proceeding against the Company 00020 arising out of or based upon: 00021 00022 (i) The combination, operation or use of the software by you with any hardware, 00023 products, programs or data not supplied or approved in writing by the Company, 00024 if such claim or proceeding would have been avoided but for such combination, 00025 operation or use. 00026 00027 (ii) The modification of the software by or on behalf of you. 00028 00029 (iii) Your use of the software. 00030 00031 THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, 00032 WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED 00033 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00034 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 00035 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 00036 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 00037 */ 00038 00039 #include <Rmp440LEInterface.h> 00040 00041 #include <math.h> 00042 #include <stdexcept> 00043 #include <sstream> 00044 00045 #include <RmpMessage.h> 00046 #include <RmpType.h> 00047 #include <RmpHelper.h> 00048 00049 namespace segway 00050 { 00051 Rmp440LEInterface::Rmp440LEInterface() 00052 : RmpInterface() 00053 { 00054 } 00055 00056 Rmp440LEInterface::~Rmp440LEInterface() 00057 { 00058 } 00059 00060 bool Rmp440LEInterface::SetVelocity(float normalizedVelocity, float normalizedYawRate) 00061 { 00062 if ((fabs(normalizedVelocity) > 1) || (fabs(normalizedYawRate) > 1)) 00063 { 00064 std::stringstream stringStream; 00065 stringStream << "Invalid velocity command. [" << normalizedVelocity << ", " << normalizedYawRate << "]. Should be within [-1, 1]"; 00066 00067 throw std::logic_error(stringStream.str()); 00068 } 00069 00070 if (m_pTransport == nullptr) 00071 { 00072 throw std::runtime_error(std::string("Initialize communication before calling any methods.")); 00073 } 00074 00075 return m_pTransport->Send(STANDARD_MOTION, ConvertFloatToUint32(normalizedVelocity), ConvertFloatToUint32(normalizedYawRate)); 00076 } 00077 00078 float Rmp440LEInterface::GetMaximumVelocity() 00079 { 00080 return GetUserDefinedFeedback<float>(FRAM_VEL_LIMIT_MPS); 00081 } 00082 00083 float Rmp440LEInterface::GetMaximumTurnRate() 00084 { 00085 return GetUserDefinedFeedback<float>(FRAM_YAW_RATE_LIMIT_RPS); 00086 } 00087 } // namespace segway