#include <NVRemoteConnection.h>
Public Member Functions | |
bool | connect () |
std::vector< std::string > | getBodyList () |
float | getJointAngle (const std::string &jointName) |
float | getJointAngleRate (const std::string &jointName) |
std::map< std::string, float > | getJointAngleRates (const std::vector< std::string > &jointList) |
std::map< std::string, float > | getJointAngles (const std::vector< std::string > &jointList) |
std::vector< float > | getJointForce (const std::string &jointName, bool firstBody=true) |
std::map< std::string, std::vector< float > > | getJointForces (const std::vector< std::string > &jointList) |
std::vector< std::string > | getJointList () |
float | getJointPosition (const std::string &jointName) |
float | getJointPositionRate (const std::string &jointName) |
std::map< std::string, float > | getJointPositionRates (const std::vector< std::string > &jointList) |
std::map< std::string, float > | getJointPositions (const std::vector< std::string > &jointList) |
std::vector< float > | getJointTorque (const std::string &jointName, bool firstBody=true) |
std::map< std::string, std::vector< float > > | getJointTorques (const std::vector< std::string > &jointList) |
std::vector< std::string > | getListForCommand (const std::string &commandName) |
std::map< std::string, float > | getMapForNodesAndCommand (const std::vector< std::string > &nodeList, float(NVRemoteConnection::*commandFunction)(const std::string &)) |
std::map< std::string, std::vector< float > > | getMapForNodesAndCommand (const std::vector< std::string > &nodeList, std::vector< float >(NVRemoteConnection::*commandFunction)(const std::string &, bool)) |
float | getValueForCommand (const std::string &commandName, const std::string &nodeName) |
std::vector< float > | getVectorForCommand (const std::string &commandName, const std::string &nodeName, bool firstBody=true) |
bool | isConnected () |
NVRemoteConnection (bool connectOnCreate=false, const std::string &hostname="localhost", unsigned int port=12345) | |
void | scheduleOde (bool scheduleSimulation=true) |
void | sendCommands () |
void | set3DVectorForCommandAndNode (const std::vector< float > &values, const std::string &commandName, const std::string &nodeName) |
void | setJointForce (const std::string &jointName, float force) |
void | setJointForce2 (const std::string &jointName, float force) |
void | setJointSpeed (const std::string &jointName, float speed) |
void | setJointSpeed2 (const std::string &jointName, float speed) |
void | setJointTorque (const std::string &jointName, float torque) |
void | setJointTorque2 (const std::string &jointName, float torque) |
void | setValueForCommandAndNode (const float &value, const std::string &commandName, const std::string &nodeName) |
~NVRemoteConnection () | |
Protected Member Functions | |
bool | receiveAnswer (std::string &answer) |
Private Attributes | |
std::ostringstream | commandStream |
CTCPSocket * | m_pSocket |
Definition at line 33 of file NVRemoteConnection.h.
NVRemoteConnection::NVRemoteConnection | ( | bool | connectOnCreate = false , |
|
const std::string & | hostname = "localhost" , |
|||
unsigned int | port = 12345 | |||
) |
Creates a new NVRemoteConnection object initialised with a hostname and a port to connect to. Opens the connection to the remote host on creation.
connectOnCreate | the connection is established if true, otherwise connect() must be called explicitely (default is false). | |
hostname | Name of the host to connect to (default is localhost). | |
port | Port on the remote host to connect to (default is 12345). |
Definition at line 56 of file NVRemoteConnection.cpp.
NVRemoteConnection::~NVRemoteConnection | ( | ) |
Closes the remote connection upon deletion of the object.
Definition at line 68 of file NVRemoteConnection.cpp.
References m_pSocket.
bool NVRemoteConnection::connect | ( | ) |
Connects to the remote viewer. This method is called by NVRemoteConnection::NVRemoteConnection if the parameter connectOnCreate is set to true.
Definition at line 655 of file NVRemoteConnection.cpp.
References m_pSocket, and CTCPSocket::openSocket().
Referenced by NVRemoteConnection().
std::vector< std::string > NVRemoteConnection::getBodyList | ( | ) |
This method sets the verbosity to 0 and afterwards calls the blist command. The returned answer is then split up into separate strings each containing the name of a body in the scene.
Definition at line 482 of file NVRemoteConnection.cpp.
References getListForCommand().
float NVRemoteConnection::getJointAngle | ( | const std::string & | jointName | ) |
jointName | the angle is returned for the joint with this name. |
Definition at line 252 of file NVRemoteConnection.cpp.
References getValueForCommand().
Referenced by getJointAngles().
float NVRemoteConnection::getJointAngleRate | ( | const std::string & | jointName | ) |
jointName | the anglerate is returned for the joint with this name. |
Definition at line 263 of file NVRemoteConnection.cpp.
References getValueForCommand().
Referenced by getJointAngleRates().
std::map< std::string, float > NVRemoteConnection::getJointAngleRates | ( | const std::vector< std::string > & | jointList | ) |
jointList | an std::vector of joint names. |
Definition at line 393 of file NVRemoteConnection.cpp.
References getJointAngleRate(), and getMapForNodesAndCommand().
std::map< std::string, float > NVRemoteConnection::getJointAngles | ( | const std::vector< std::string > & | jointList | ) |
jointList | an std::vector of joint names. |
Definition at line 380 of file NVRemoteConnection.cpp.
References getJointAngle(), and getMapForNodesAndCommand().
std::vector< float > NVRemoteConnection::getJointForce | ( | const std::string & | jointName, | |
bool | firstBody = true | |||
) |
Retrieves the forces appearing in the joint supplied as parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
firstBody | If true uses the first body connected to the joint for calculationg the forces otherwise the second one (default = true). |
Definition at line 198 of file NVRemoteConnection.cpp.
References getVectorForCommand().
Referenced by getJointForces().
std::map< std::string, std::vector< float > > NVRemoteConnection::getJointForces | ( | const std::vector< std::string > & | jointList | ) |
jointList | an std::vector of joint names. |
Definition at line 353 of file NVRemoteConnection.cpp.
References getJointForce(), and getMapForNodesAndCommand().
Referenced by sendCommands().
std::vector< std::string > NVRemoteConnection::getJointList | ( | ) |
This method sets the verbosity to 0 and afterwards calls the jlist command. The returned answer is then split up into separate strings each containing the name of a joint in the scene.
Definition at line 469 of file NVRemoteConnection.cpp.
References getListForCommand().
Referenced by sendCommands().
float NVRemoteConnection::getJointPosition | ( | const std::string & | jointName | ) |
jointName | the position is returned for the joint with this name. |
Definition at line 274 of file NVRemoteConnection.cpp.
References getValueForCommand().
Referenced by getJointPositions().
float NVRemoteConnection::getJointPositionRate | ( | const std::string & | jointName | ) |
jointName | the positionrate is returned for the joint with this name. |
Definition at line 285 of file NVRemoteConnection.cpp.
References getValueForCommand().
Referenced by getJointPositionRates().
std::map< std::string, float > NVRemoteConnection::getJointPositionRates | ( | const std::vector< std::string > & | jointList | ) |
jointList | an std::vector of joint names. |
Definition at line 419 of file NVRemoteConnection.cpp.
References getJointPositionRate(), and getMapForNodesAndCommand().
std::map< std::string, float > NVRemoteConnection::getJointPositions | ( | const std::vector< std::string > & | jointList | ) |
jointList | an std::vector of joint names. |
Definition at line 406 of file NVRemoteConnection.cpp.
References getJointPosition(), and getMapForNodesAndCommand().
std::vector< float > NVRemoteConnection::getJointTorque | ( | const std::string & | jointName, | |
bool | firstBody = true | |||
) |
Retrieves the torques appearing in the joint supplied as parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
firstBody | If true uses the first body connected to the joint for calculationg the torques otherwise the second one. Default is true. |
Definition at line 215 of file NVRemoteConnection.cpp.
References getVectorForCommand().
Referenced by getJointTorques().
std::map< std::string, std::vector< float > > NVRemoteConnection::getJointTorques | ( | const std::vector< std::string > & | jointList | ) |
jointList | an std::vector of joint names. |
Definition at line 367 of file NVRemoteConnection.cpp.
References getJointTorque(), and getMapForNodesAndCommand().
std::vector< std::string > NVRemoteConnection::getListForCommand | ( | const std::string & | commandName | ) |
This method sets the verbosity to 0 and afterwards calls the command specified as parameter. The returned answer is then split up into separate strings. The split occurs at the '
' (newline) character
commandName | the command to send to the networkviewer (jlist or blist for example). |
Definition at line 434 of file NVRemoteConnection.cpp.
References commandStream, m_pSocket, receiveAnswer(), and CTCPSocket::send().
Referenced by getBodyList(), and getJointList().
std::map< std::string, float > NVRemoteConnection::getMapForNodesAndCommand | ( | const std::vector< std::string > & | nodeList, | |
float(NVRemoteConnection::*)(const std::string &) | commandFunction | |||
) |
This method calls the supplied function for each of the elements in nodeList and returns a mapping between each nodeList element and the result of the function call.
nodeList | an std::vector of std::strings (usually joint names) | |
commandFunction | the function to call for each element (this must be a method of NVRemoteConnection which has the same signature as the function pointer). |
Definition at line 326 of file NVRemoteConnection.cpp.
std::map< std::string, std::vector< float > > NVRemoteConnection::getMapForNodesAndCommand | ( | const std::vector< std::string > & | nodeList, | |
std::vector< float >(NVRemoteConnection::*)(const std::string &, bool) | commandFunction | |||
) |
This method calls the supplied function for each of the elements in nodeList and returns a mapping between each nodeList element and the result of the function call.
nodeList | an std::vector of std::strings (usually joint names) | |
commandFunction | the function to call for each element (this must be a method of NVRemoteConnection which has the same signature as the function pointer). |
Definition at line 299 of file NVRemoteConnection.cpp.
Referenced by getJointAngleRates(), getJointAngles(), getJointForces(), getJointPositionRates(), getJointPositions(), and getJointTorques().
float NVRemoteConnection::getValueForCommand | ( | const std::string & | commandName, | |
const std::string & | nodeName | |||
) |
Assembles the command from commandName and nodeName parameter and returns the float value of the command.
commandName | the command to send (must return a float value). | |
nodeName | the name of the node the command uses to return a value. |
Definition at line 230 of file NVRemoteConnection.cpp.
References commandStream, m_pSocket, receiveAnswer(), and CTCPSocket::send().
Referenced by getJointAngle(), getJointAngleRate(), getJointPosition(), and getJointPositionRate().
std::vector< float > NVRemoteConnection::getVectorForCommand | ( | const std::string & | commandName, | |
const std::string & | nodeName, | |||
bool | firstBody = true | |||
) |
Generic method which sends a command and a node name to the networkviewer and returns the answered vector. This method should be used by all other getX() commands.
commandName | the name of the command to send to the viewer | |
nodeName | name of the body or joint to query | |
firstBody | bool for the jointtorque and jointforce commands. It tells which body to use. |
Definition at line 169 of file NVRemoteConnection.cpp.
References commandStream, m_pSocket, receiveAnswer(), and CTCPSocket::send().
Referenced by getJointForce(), and getJointTorque().
bool NVRemoteConnection::isConnected | ( | ) |
Returns the status of the remote connection.
Definition at line 666 of file NVRemoteConnection.cpp.
References CTCPSocket::isConnected(), and m_pSocket.
bool NVRemoteConnection::receiveAnswer | ( | std::string & | answer | ) | [protected] |
Receives an answer from the socket and returns it.
answer | contains the received answer or "" if a socket error occured. |
Definition at line 620 of file NVRemoteConnection.cpp.
References m_pSocket, CTCPSocket::receive(), and CTCPSocket::setNonBlocking().
Referenced by getListForCommand(), getValueForCommand(), and getVectorForCommand().
void NVRemoteConnection::scheduleOde | ( | bool | scheduleSimulation = true |
) |
Sends the (un-)schedule command to the NetworkViewer to (stop)start the simulation.
scheduleSimulation | schedules the simulation if true, otherwise unschedules it (default is true). |
Definition at line 147 of file NVRemoteConnection.cpp.
References m_pSocket, and CTCPSocket::send().
Referenced by sendCommands().
void NVRemoteConnection::sendCommands | ( | ) |
Sends some commands and prints the answer if available. Currently interacts with a joint from the file joint-test.iv.
Definition at line 81 of file NVRemoteConnection.cpp.
References getJointForces(), getJointList(), scheduleOde(), and setJointSpeed().
void NVRemoteConnection::set3DVectorForCommandAndNode | ( | const std::vector< float > & | values, | |
const std::string & | commandName, | |||
const std::string & | nodeName | |||
) |
Generic method which checks if the supplied value vector is of size 3 and afterwards assembles the command by appending commandName with nodeName and the three values of the value vector.
values | a 3D vectors of the values to set on the node given by nodeName. | |
commandName | the name of the command to send to the viewer. | |
nodeName | the name of the node (usually a joint) on which the command should be executed. |
Definition at line 500 of file NVRemoteConnection.cpp.
References commandStream, m_pSocket, and CTCPSocket::send().
void NVRemoteConnection::setJointForce | ( | const std::string & | jointName, | |
float | force | |||
) |
Sets the force supplied as parameter on the joint specified in the first parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
force | the force value to set. |
Definition at line 542 of file NVRemoteConnection.cpp.
References setValueForCommandAndNode().
void NVRemoteConnection::setJointForce2 | ( | const std::string & | jointName, | |
float | force2 | |||
) |
Sets the force2 supplied as parameter on the joint specified in the first parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
force2 | the force2 value to set. |
Definition at line 554 of file NVRemoteConnection.cpp.
References setValueForCommandAndNode().
void NVRemoteConnection::setJointSpeed | ( | const std::string & | jointName, | |
float | speed | |||
) |
Sets the speed supplied as parameter on the joint specified in the first parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
speed | the speed value to set. |
Definition at line 566 of file NVRemoteConnection.cpp.
References setValueForCommandAndNode().
Referenced by sendCommands().
void NVRemoteConnection::setJointSpeed2 | ( | const std::string & | jointName, | |
float | speed2 | |||
) |
Sets the speed2 supplied as parameter on the joint specified in the first parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
speed2 | the speed2 value to set. |
Definition at line 578 of file NVRemoteConnection.cpp.
References setValueForCommandAndNode().
void NVRemoteConnection::setJointTorque | ( | const std::string & | jointName, | |
float | torque | |||
) |
Sets the torque supplied as parameter on the joint specified in the first parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
torque | the torque value to set. |
Definition at line 590 of file NVRemoteConnection.cpp.
References setValueForCommandAndNode().
void NVRemoteConnection::setJointTorque2 | ( | const std::string & | jointName, | |
float | torque2 | |||
) |
Sets the torque2 supplied as parameter on the joint specified in the first parameter.
jointName | Name of the Open Inventor node in the scenegraph. | |
torque2 | the torque2 value to set. |
Definition at line 602 of file NVRemoteConnection.cpp.
References setValueForCommandAndNode().
void NVRemoteConnection::setValueForCommandAndNode | ( | const float & | value, | |
const std::string & | commandName, | |||
const std::string & | nodeName | |||
) |
Generic method which assembles the command by appending commandName with nodeName and the given value.
value | the value to set on the node given by nodeName. | |
commandName | the name of the command to send to the viewer. | |
nodeName | the name of the node (usually a joint) on which the command should be executed. |
Definition at line 526 of file NVRemoteConnection.cpp.
References commandStream, m_pSocket, and CTCPSocket::send().
Referenced by setJointForce(), setJointForce2(), setJointSpeed(), setJointSpeed2(), setJointTorque(), and setJointTorque2().
NVRemoteConnection::commandStream [private] |
Instance of std::ostringstream used to assemble commands.
Definition at line 83 of file NVRemoteConnection.h.
Referenced by getListForCommand(), getValueForCommand(), getVectorForCommand(), set3DVectorForCommandAndNode(), and setValueForCommandAndNode().
NVRemoteConnection::m_pSocket [private] |
Socket used for communication with the remote host.
Definition at line 82 of file NVRemoteConnection.h.
Referenced by connect(), getListForCommand(), getValueForCommand(), getVectorForCommand(), isConnected(), NVRemoteConnection(), receiveAnswer(), scheduleOde(), set3DVectorForCommandAndNode(), setValueForCommandAndNode(), and ~NVRemoteConnection().
Generated on Sat Mar 10 20:00:19 2012 for IPSA by 1.5.8 |