00001 #ifndef _NV_REMOTE_CONNECTION_H_
00002 #define _NV_REMOTE_CONNECTION_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "../IPSA.h"
00025
00026 #include <string>
00027 #include <vector>
00028 #include <map>
00029 #include <sstream>
00030
00031 class CTCPSocket;
00032
00033 class IPSA_TOOLS_IMPORT_EXPORT NVRemoteConnection
00034 {
00035 public:
00036 NVRemoteConnection(bool connectOnCreate = false, const std::string& hostname = "localhost", unsigned int port = 12345);
00037 ~NVRemoteConnection();
00038
00039 bool connect();
00040 bool isConnected();
00041
00042 void sendCommands();
00043
00044 void scheduleOde(bool scheduleSimulation = true);
00045
00046
00047 std::vector<float> getVectorForCommand(const std::string& commandName, const std::string& nodeName, bool firstBody = true);
00048 std::vector<float> getJointForce(const std::string& jointName, bool firstBody = true);
00049 std::vector<float> getJointTorque(const std::string& jointName, bool firstBody = true);
00050 float getValueForCommand(const std::string& commandName, const std::string& nodeName);
00051 float getJointAngle(const std::string& jointName);
00052 float getJointAngleRate(const std::string& jointName);
00053 float getJointPosition(const std::string& jointName);
00054 float getJointPositionRate(const std::string& jointName);
00055
00056
00057 std::map<std::string, std::vector<float> > getMapForNodesAndCommand(const std::vector<std::string>& nodeList, std::vector<float> (NVRemoteConnection::*commandFunction)(const std::string&, bool));
00058 std::map<std::string, float> getMapForNodesAndCommand(const std::vector<std::string>& nodeList, float (NVRemoteConnection::*commandFunction)(const std::string&));
00059 std::map<std::string, std::vector<float> > getJointForces(const std::vector<std::string>& jointList);
00060 std::map<std::string, std::vector<float> > getJointTorques(const std::vector<std::string>& jointList);
00061 std::map<std::string, float> getJointAngles(const std::vector<std::string>& jointList);
00062 std::map<std::string, float> getJointAngleRates(const std::vector<std::string>& jointList);
00063 std::map<std::string, float> getJointPositions(const std::vector<std::string>& jointList);
00064 std::map<std::string, float> getJointPositionRates(const std::vector<std::string>& jointList);
00065 std::vector<std::string> getListForCommand(const std::string& commandName);
00066 std::vector<std::string> getJointList();
00067 std::vector<std::string> getBodyList();
00068
00069
00070 void set3DVectorForCommandAndNode(const std::vector<float>& values, const std::string& commandName, const std::string& nodeName);
00071 void setValueForCommandAndNode(const float& value, const std::string& commandName, const std::string& nodeName);
00072 void setJointForce(const std::string& jointName, float force);
00073 void setJointForce2(const std::string& jointName, float force);
00074 void setJointSpeed(const std::string& jointName, float speed);
00075 void setJointSpeed2(const std::string& jointName, float speed);
00076 void setJointTorque(const std::string& jointName, float torque);
00077 void setJointTorque2(const std::string& jointName, float torque);
00078
00079 protected:
00080 bool receiveAnswer(std::string& answer);
00081 private:
00082 CTCPSocket* m_pSocket;
00083 std::ostringstream commandStream;
00084 };
00085
00086 #endif // _NV_REMOTE_CONNECTION_H_