Skip to content

Commit

Permalink
RPC Support added to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
mani-monaj committed Mar 11, 2012
1 parent a9da31c commit c4c632a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions librapirpc/robotrpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ bool RobotRpcClient::getWheelDropDev(unsigned int& numSamples)
numSamples = fromVariant<int>(result["numSamples"]);
return true;
}
//------------------------------------------------------------------------------
bool RobotRpcClient::getCliffDev(unsigned int& numSamples)
{
object result = call("getCliffDev", object());
numSamples = fromVariant<int>(result["numSamples"]);
return true;
}

//------------------------------------------------------------------------------
void RobotRpcClient::getDrivetrain( bool &isStalled,
Expand Down Expand Up @@ -180,5 +187,17 @@ std::vector<bool> RobotRpcClient::getWheelDrops( void )
return out;
}
//------------------------------------------------------------------------------
std::vector<bool> RobotRpcClient::getCliffs( void )
{
std::vector<bool> out;
object result = call("getCliffs", object() );
array cliffs = fromVariant<array>(result["cliffs"]);
for (unsigned int i = 0; i < cliffs.size(); ++i)
{
out.push_back(fromVariant<bool> (cliffs[i]));
}
return out;
}
//------------------------------------------------------------------------------

} // namespace
13 changes: 13 additions & 0 deletions librapirpc/robotrpcclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class RobotRpcClient
*/
bool getWheelDropDev( unsigned int &numSamples);

/**
* Get the parameters of cliff device if exists
* @param numSamples
* @return 1 if successful, otherwise 0
*/
bool getCliffDev( unsigned int &numSamples);

//---- device get/set calls --------------------------------------------------
/** get position and velocity information */
void getDrivetrain( bool &isStalled,
Expand Down Expand Up @@ -99,6 +106,12 @@ class RobotRpcClient
*/
std::vector<bool> getWheelDrops(void);

/**
* Get cliffs status
* @return
*/
std::vector<bool> getCliffs(void);

private:
/** helper method for performing RPC calls */
jsonrpc::object call( std::string methodName, jsonrpc::object args );
Expand Down
6 changes: 6 additions & 0 deletions librapirpc/simplerpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ int main (int argc, char* argv[])
double maxCapacity;
unsigned int numBumpers;
unsigned int numWheels;
unsigned int numCliffs;
std::vector<float> ranges;
std::vector<bool> bumpers;
std::vector<bool> wheels;
std::vector<bool> cliffs;
while (true)
{
std::cout << "Testing robot " << address << std::endl;
Expand All @@ -40,6 +42,10 @@ int main (int argc, char* argv[])
wheels = robot->getWheelDrops();
std::cout << "WheelDrop Count: " << numWheels << std::endl;
std::cout << "WheelDrop Status : " << wheels[0] << " , " << wheels[1] << std::endl;
numWheels = robot->getWheelDropDev(numCliffs);
cliffs = robot->getCliffs();
std::cout << "Cliffs Count: " << numCliffs << std::endl;
std::cout << "Cliffs Status : " << cliffs[0] << " , " << cliffs[1] << std::endl;
usleep(500000); // Please don't overload robot
}
//robot->quit();
Expand Down

0 comments on commit c4c632a

Please sign in to comment.