You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

99 lines
3.3 KiB

#include "defines.h"
#include "StringTool.h"
#include <string>
#include "friremote.h"
#ifndef SVR_HANDLING
#define SVR_HANDLING
// Serve status
#define SVR_NAME "lwrsvr 4.11d"
#define SVR_DEFAULT_PORT 8000
#define SVR_HANDSHAKE "Hello Robot"
#define SVR_HELLO_MSG std::string("welcome to ") + SVR_NAME + ("!") + (" Type \"")+ SVR_HANDSHAKE + ("\" to establish the connection")
#define SVR_ACCEPTED std::string("accepted")
#define SVR_FAILED std::string("Failed.")
#define SVR_TRUE_RSP "true"
#define SVR_FALSE_RSP "false"
// server error messages
#define SVR_INVALID_ARGUMENT "ERROR: The argument is not correct."
#define SVR_UNIMPLEMENTED_COMMAND "ERROR: This command is jet not implemented."
#define SVR_UNKNOWN_COMMAND "ERROR: This command is not correct."
#define SVR_INVALID_ARGUMENT_COUNT "ERROR: The argument count is not correct."
#define SVR_OUT_OF_RANGE "ERROR: At least one argument is out of Range."
typedef enum {waiting, handshake, accepted, done} svr_state;
class SvrHandling : private StringTool
{
private:
svr_state c_state;
//Handshake
bool handshakeAccepted(SocketObject& client);
//handle client commands he is disconected
void clientCommandLoop(SocketObject& client);
public:
//Constructor
SvrHandling();
//Destructor
virtual ~SvrHandling();
///Run server with default port
void run();
///Run server special port
void run(int port);
//Get current timestamp
std::string timestamp();
};
struct ClientCommand
{
std::string aberration;
std::string longVersion;
void (*processCommand) ( SocketObject& client, std::string& argv);
void (*printHelp) (void);
};
static struct ClientCommand* commands;
static unsigned int commandCount;
void printUsage(SocketObject& client, std::string& arg);
//Handling request for current Joint Values
void getPositionJoints(SocketObject& client, std::string& arg);
//Get Position as POSE Matrix
void getPositionHomRowWise(SocketObject& client, std::string& arg);
//Get Force/torque values from TCP
void getForceTorqueTcp(SocketObject& client, std::string& arg);
//Move to given Joint combination
void movePTPJoints(SocketObject& client, std::string& arg);
//Move to given POSE position
void moveHomRowWiseStatus(SocketObject& client, std::string& arg);
//Set Velocity
void setSpeed(SocketObject& client, std::string& arg);
//Set Acceleration
void setAccel(SocketObject& client, std::string& arg);
//Starting Potential Field Movement Mode
void startPotFieldMode(SocketObject& client, std::string& arg);
//Stopping Potential Field Movement Mode
void stopPotFieldMode(SocketObject& client, std::string& arg);
//Setting Target Position HomRowWise for Potential Move
void setPos(SocketObject& client, std::string& arg);
//Setting Target Position as Joints for Potential Move
void setJoints(SocketObject& client, std::string& arg);
//Cartesian Movement
//Move to given POSE position
void moveCartesian(SocketObject& client, std::string& arg);
// set a specific trajectory type
void setTrajectoryType(SocketObject& client, std::string& arg);
void getTrajectoryType(SocketObject& client, std::string& arg);
//Quit
void quit(SocketObject& client, std::string& arg);
//DEBUGGING
void debug(SocketObject& client, std::string& arg);
#endif