Browse Source

add help and deailed help function

master
philipp schoenberger 10 years ago
parent
commit
0d60e2835d
  1. 2
      lwrserv/include/BangBangTrajectory.h
  2. 2
      lwrserv/include/SvrHandling.h
  3. 26
      lwrserv/include/commandsHelp.h
  4. 55
      lwrserv/src/SvrHandling.cpp
  5. 125
      lwrserv/src/commandsHelp.cpp

2
lwrserv/include/BangBangTrajectory.h

@ -34,7 +34,6 @@
* The slowest joint is defining the speed of the other joints. * The slowest joint is defining the speed of the other joints.
* By that all joints start and stop the movement synchronously * By that all joints start and stop the movement synchronously
*/ */
template <unsigned SIZE>
/** /**
* Class for a Bang Bang Trajectory based on joint angles. * Class for a Bang Bang Trajectory based on joint angles.
@ -45,6 +44,7 @@ template <unsigned SIZE>
* *
* @see Trajectory * @see Trajectory
*/ */
template <unsigned SIZE>
class BangBangJointTrajectory : public Trajectory<SIZE> class BangBangJointTrajectory : public Trajectory<SIZE>
{ {
public: public:

2
lwrserv/include/SvrHandling.h

@ -59,6 +59,6 @@ struct ClientCommand
std::string aberration; std::string aberration;
std::string longVersion; std::string longVersion;
void (*processCommand) ( SocketObject& client, std::string& argv); void (*processCommand) ( SocketObject& client, std::string& argv);
void (*printHelp) (void);
void (*printHelp) ( SocketObject& client);
}; };
#endif #endif

26
lwrserv/include/commandsHelp.h

@ -12,31 +12,31 @@
*/ */
//Handling request for current Joint Values //Handling request for current Joint Values
void getPositionJointsHelp (SocketObject& client, std::string& arg);
void getPositionJointsHelp (SocketObject& client);
//Get Position as POSE Matrix //Get Position as POSE Matrix
void getPositionHomRowWiseHelp (SocketObject& client, std::string& arg);
void getPositionHomRowWiseHelp (SocketObject& client);
//Get Force/torque values from TCP //Get Force/torque values from TCP
void getForceTorqueTcpHelp (SocketObject& client, std::string& arg);
void getForceTorqueTcpHelp (SocketObject& client);
//Move to given Joint combination //Move to given Joint combination
void movePTPJointsHelp (SocketObject& client, std::string& arg);
void movePTPJointsHelp (SocketObject& client);
//Move to given POSE position //Move to given POSE position
void moveHomRowWiseStatusHelp (SocketObject& client, std::string& arg);
void moveHomRowWiseStatusHelp (SocketObject& client);
//Set Velocity //Set Velocity
void setSpeedHelp (SocketObject& client, std::string& arg);
void setSpeedHelp (SocketObject& client);
//Set Acceleration //Set Acceleration
void setAccelHelp (SocketObject& client, std::string& arg);
void setAccelHelp (SocketObject& client);
//Starting Potential Field Movement Mode //Starting Potential Field Movement Mode
void startPotFieldModeHelp (SocketObject& client, std::string& arg);
void startPotFieldModeHelp (SocketObject& client);
//Stopping Potential Field Movement Mode //Stopping Potential Field Movement Mode
void stopPotFieldModeHelp (SocketObject& client, std::string& arg);
void stopPotFieldModeHelp (SocketObject& client);
// set the current trajectory type // set the current trajectory type
void setTrajectoryTypeHelp (SocketObject& client, std::string& arg);
void setTrajectoryTypeHelp (SocketObject& client);
// get the current trajectory type // get the current trajectory type
void getTrajectoryTypeHelp (SocketObject& client, std::string& arg);
void getTrajectoryTypeHelp (SocketObject& client);
//Quit //Quit
void quitHelp (SocketObject& client, std::string& arg);
void quitHelp (SocketObject& client);
// check if we use a kuka // check if we use a kuka
void isKukaLwrHelp (SocketObject& client, std::string& arg);
void isKukaLwrHelp (SocketObject& client);
/** /**
* @} * @}

55
lwrserv/src/SvrHandling.cpp

@ -9,6 +9,7 @@
#include "SvrHandling.h" #include "SvrHandling.h"
#include "SvrData.h" #include "SvrData.h"
#include "commands.h" #include "commands.h"
#include "commandsHelp.h"
#include "Trajectroy.h" #include "Trajectroy.h"
#include "LinearTrajectory.h" #include "LinearTrajectory.h"
@ -18,16 +19,32 @@
* @param client The reference to the client socket Object to exchange messages * @param client The reference to the client socket Object to exchange messages
* @param arg Unused parameter to match Signature of normal commands. * @param arg Unused parameter to match Signature of normal commands.
*/ */
void printUsage(SocketObject& client, std::string& arg)
void printUsage(SocketObject& client, std::string& cmd)
{ {
(void) arg;
for (unsigned int i = 0 ; i < commandCount; ++i) for (unsigned int i = 0 ; i < commandCount; ++i)
{ {
if(commands[i].printHelp != NULL)
commands[i].printHelp();
else
if (cmd == commands[i].longVersion || cmd == commands[i].aberration)
{
// print short version first
client.Send(commands[i].aberration+"\t-\t"+commands[i].longVersion); client.Send(commands[i].aberration+"\t-\t"+commands[i].longVersion);
// print detailed help text for this command
if(commands[i].printHelp != NULL)
commands[i].printHelp(client);
return;
}
}
// no command was specified.
// print only short versions of the commands
client.Send("List of Commands with aberration and long form\n For detailed help try \"help <commandname>\"\n");
client.Send("short version \t-\t long version\n");
for (unsigned int i = 0 ; i < commandCount; ++i)
{
client.Send(commands[i].aberration+"\t-\t"+commands[i].longVersion);
} }
} }
@ -44,52 +61,52 @@ SvrHandling::SvrHandling()
commands[i].aberration = "GPJ"; commands[i].aberration = "GPJ";
commands[i].longVersion = "GetPositionJoints"; commands[i].longVersion = "GetPositionJoints";
commands[i].processCommand = &getPositionJoints; commands[i].processCommand = &getPositionJoints;
commands[i].printHelp = NULL;
commands[i].printHelp = &getPositionJointsHelp;
i+=1; i+=1;
commands[i].aberration = "GPHRW"; commands[i].aberration = "GPHRW";
commands[i].longVersion = "GetPositionHomRowWise"; commands[i].longVersion = "GetPositionHomRowWise";
commands[i].processCommand = &getPositionHomRowWise; commands[i].processCommand = &getPositionHomRowWise;
commands[i].printHelp = NULL;
commands[i].printHelp = &getPositionHomRowWiseHelp;
i+=1; i+=1;
commands[i].aberration = "GFT"; commands[i].aberration = "GFT";
commands[i].longVersion = "GetForceTorqueTcp"; commands[i].longVersion = "GetForceTorqueTcp";
commands[i].processCommand = &getForceTorqueTcp; commands[i].processCommand = &getForceTorqueTcp;
commands[i].printHelp = NULL;
commands[i].printHelp = &getForceTorqueTcpHelp;
i+=1; i+=1;
commands[i].aberration = "MPTPJ"; commands[i].aberration = "MPTPJ";
commands[i].longVersion = "MovePTPJoints"; commands[i].longVersion = "MovePTPJoints";
commands[i].processCommand = &movePTPJoints; commands[i].processCommand = &movePTPJoints;
commands[i].printHelp = NULL;
commands[i].printHelp = &movePTPJointsHelp;
i+=1; i+=1;
commands[i].aberration = "MHRWS"; commands[i].aberration = "MHRWS";
commands[i].longVersion = "MoveHomRowWiseStatus"; commands[i].longVersion = "MoveHomRowWiseStatus";
commands[i].processCommand = &moveHomRowWiseStatus; commands[i].processCommand = &moveHomRowWiseStatus;
commands[i].printHelp = NULL;
commands[i].printHelp = &moveHomRowWiseStatusHelp;
i+=1; i+=1;
commands[i].aberration = "SS"; commands[i].aberration = "SS";
commands[i].longVersion = "SetSpeed"; commands[i].longVersion = "SetSpeed";
commands[i].processCommand = &setSpeed; commands[i].processCommand = &setSpeed;
commands[i].printHelp = NULL;
commands[i].printHelp = &setSpeedHelp;
i+=1; i+=1;
commands[i].aberration = "SA"; commands[i].aberration = "SA";
commands[i].longVersion = "SetAccel"; commands[i].longVersion = "SetAccel";
commands[i].processCommand = &setAccel; commands[i].processCommand = &setAccel;
commands[i].printHelp = NULL;
commands[i].printHelp = &setAccelHelp;
i+=1; i+=1;
commands[i].aberration = "STPF"; commands[i].aberration = "STPF";
commands[i].longVersion = "StartPotFieldMode"; commands[i].longVersion = "StartPotFieldMode";
commands[i].processCommand = &startPotFieldMode; commands[i].processCommand = &startPotFieldMode;
commands[i].printHelp = NULL;
commands[i].printHelp = &startPotFieldModeHelp;
i+=1; i+=1;
commands[i].aberration = "SPPF"; commands[i].aberration = "SPPF";
commands[i].longVersion = "StopPotFieldMode"; commands[i].longVersion = "StopPotFieldMode";
commands[i].processCommand = &stopPotFieldMode; commands[i].processCommand = &stopPotFieldMode;
commands[i].printHelp = NULL;
commands[i].printHelp = &stopPotFieldModeHelp;
i+=1; i+=1;
commands[i].aberration = "Q"; commands[i].aberration = "Q";
commands[i].longVersion = "Quit"; commands[i].longVersion = "Quit";
commands[i].processCommand = &quit; commands[i].processCommand = &quit;
commands[i].printHelp = NULL;
commands[i].printHelp = &quitHelp;
i+=1; i+=1;
commands[i].aberration = "?"; commands[i].aberration = "?";
commands[i].longVersion = "Help"; commands[i].longVersion = "Help";
@ -99,17 +116,17 @@ SvrHandling::SvrHandling()
commands[i].aberration = "ISKUKA"; commands[i].aberration = "ISKUKA";
commands[i].longVersion = "IsKukaLWR"; commands[i].longVersion = "IsKukaLWR";
commands[i].processCommand = &isKukaLwr; commands[i].processCommand = &isKukaLwr;
commands[i].printHelp = NULL;
commands[i].printHelp = &isKukaLwrHelp;
i+=1; i+=1;
commands[i].aberration = "GT"; commands[i].aberration = "GT";
commands[i].longVersion = "GetTrajectoryType"; commands[i].longVersion = "GetTrajectoryType";
commands[i].processCommand = &getTrajectoryType; commands[i].processCommand = &getTrajectoryType;
commands[i].printHelp = NULL;
commands[i].printHelp = &getTrajectoryTypeHelp;
i+=1; i+=1;
commands[i].aberration = "ST"; commands[i].aberration = "ST";
commands[i].longVersion = "SetTrajectoryType"; commands[i].longVersion = "SetTrajectoryType";
commands[i].processCommand = &setTrajectoryType; commands[i].processCommand = &setTrajectoryType;
commands[i].printHelp = NULL;
commands[i].printHelp = &setTrajectoryTypeHelp;
i+=1; i+=1;
commandCount = i; commandCount = i;
@ -414,7 +431,7 @@ void SvrHandling::clientCommandLoop(SocketObject& client)
{ {
// send returnvalue and print help // send returnvalue and print help
client.Send(SVR_UNKNOWN_COMMAND); client.Send(SVR_UNKNOWN_COMMAND);
printUsage(client, arg);
printUsage(client, cmd);
} }
}else }else

125
lwrserv/src/commandsHelp.cpp

@ -25,21 +25,18 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "SocketObject.h" #include "SocketObject.h"
#include "Trajectroy.h"
/** /**
* This function returns the help information text to the client * This function returns the help information text to the client
* for the getPositionJoints function. * for the getPositionJoints function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see getPositionJoints * @see getPositionJoints
*/ */
void getPositionJointsHelp(SocketObject& client, std::string& arg)
void getPositionJointsHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
@ -56,15 +53,11 @@ void getPositionJointsHelp(SocketObject& client, std::string& arg)
* for the getPositionHomRowWise function. * for the getPositionHomRowWise function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see getPositionHomRowWise * @see getPositionHomRowWise
*/ */
void getPositionHomRowWiseHelp(SocketObject& client, std::string& arg)
void getPositionHomRowWiseHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
@ -91,15 +84,11 @@ void getPositionHomRowWiseHelp(SocketObject& client, std::string& arg)
* for the getForceTorqueTcp function. * for the getForceTorqueTcp function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see getForceTorqueTcp * @see getForceTorqueTcp
*/ */
void getForceTorqueTcpHelp(SocketObject& client, std::string& arg)
void getForceTorqueTcpHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
@ -119,15 +108,11 @@ void getForceTorqueTcpHelp(SocketObject& client, std::string& arg)
* for the movePTPJoints function. * for the movePTPJoints function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see movePTPJoints * @see movePTPJoints
*/ */
void movePTPJointsHelp(SocketObject& client, std::string& arg)
void movePTPJointsHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
@ -151,18 +136,17 @@ void movePTPJointsHelp(SocketObject& client, std::string& arg)
* for the moveHomRowWiseStatus function. * for the moveHomRowWiseStatus function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see moveHomRowWiseStatus * @see moveHomRowWiseStatus
*/ */
void moveHomRowWiseStatusHelp(SocketObject& client, std::string& arg)
void moveHomRowWiseStatusHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// add the help text to the buffer
out += "\n";
// send message to client // send message to client
client.Send(out); client.Send(out);
} }
@ -172,18 +156,21 @@ void moveHomRowWiseStatusHelp(SocketObject& client, std::string& arg)
* for the setSpeed function. * for the setSpeed function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see setSpeed * @see setSpeed
*/ */
void setSpeedHelp(SocketObject& client, std::string& arg)
void setSpeedHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// add the help text to the buffer
out += "The velocity percentage of the robot.\n";
out += "The percentage value has to be positive and \n";
out += "within the interval of \"(0 100]\". If the new \n";
out += "value is a valid one the return string will be \"true\"\n";
out += "otherwise \"false\"\n";
// send message to client // send message to client
client.Send(out); client.Send(out);
} }
@ -193,17 +180,20 @@ void setSpeedHelp(SocketObject& client, std::string& arg)
* for the setAccel function. * for the setAccel function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see setAccel * @see setAccel
*/ */
void setAccelHelp(SocketObject& client, std::string& arg)
void setAccelHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// add the help text to the buffer
out += "The acceleration percentage of the robot.\n";
out += "The percentage value has to be positive and \n";
out += "within the interval of \"(0 100]\". If the new \n";
out += "value is a valid one the return string will be \"true\"\n";
out += "otherwise \"false\"\n";
// send message to client // send message to client
client.Send(out); client.Send(out);
@ -214,18 +204,21 @@ void setAccelHelp(SocketObject& client, std::string& arg)
* for the startPotFieldMode function. * for the startPotFieldMode function.
* *
* @param client connection to client which will receive the response * @param client connection to client which will receive the response
* @param arg unused but has to be there for matching the signature
* *
* @see startPotFieldMode * @see startPotFieldMode
*/ */
void startPotFieldModeHelp(SocketObject& client, std::string& arg)
void startPotFieldModeHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// add the help text to the buffer
out += "This command starts the PotFieldMode and deactivate the TrajectoryType\n";
out += "The PotFieldMode is a mode with no trajectory planing\n";
out += "The entered joint movements are directly executed by \n";
out += "the robot. The Robot itself might stop and block motors\n";
out += "if the Acceleration and Velocity is to high\n";
// send message to client // send message to client
client.Send(out); client.Send(out);
} }
@ -239,14 +232,18 @@ void startPotFieldModeHelp(SocketObject& client, std::string& arg)
* *
* @see stopPotFieldMode * @see stopPotFieldMode
*/ */
void stopPotFieldModeHelp(SocketObject& client, std::string& arg)
void stopPotFieldModeHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// add the help text to the buffer
out += "This command stops the PotFieldMode and activates the TrajectoryType again\n";
out += "The PotFieldMode is a mode with no trajectory planing\n";
out += "The entered joint movements are directly executed by \n";
out += "the robot. The Robot itself might stop and block motors\n";
out += "if the Acceleration and Velocity is to high\n";
// send message to client // send message to client
client.Send(out); client.Send(out);
} }
@ -260,14 +257,15 @@ void stopPotFieldModeHelp(SocketObject& client, std::string& arg)
* *
* @see quit * @see quit
*/ */
void quitHelp(SocketObject& client , std::string& arg)
void quitHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// add the help text to the buffer
out += "This command stops the communication so an other user might\n";
out += "be able to connect.\n";
// send message to client // send message to client
client.Send(out); client.Send(out);
} }
@ -281,14 +279,23 @@ void quitHelp(SocketObject& client , std::string& arg)
* *
* @see quit * @see quit
*/ */
void setTrajectoryTypeHelp(SocketObject& client, std::string& arg)
void setTrajectoryTypeHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// add the help text to the buffer
out += "This command sets the type of the Trajectory for all kind of\n";
out += "movements.\n";
out += "The possible Trajectory types are:\n";
initTrajectoryType();
int items = __TrajectoryCount;
for (int i = 0 ; i < items ; ++i)
{
out += "\t " + trajectoryTypeStr[i].str + "\n";
}
// send message to client // send message to client
client.Send(out); client.Send(out);
} }
@ -302,11 +309,8 @@ void setTrajectoryTypeHelp(SocketObject& client, std::string& arg)
* *
* @see getTrajectoryType * @see getTrajectoryType
*/ */
void getTrajectoryTypeHelp(SocketObject& client, std::string& arg)
void getTrajectoryTypeHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
@ -323,14 +327,15 @@ void getTrajectoryTypeHelp(SocketObject& client, std::string& arg)
* *
* @see isKukaLwr * @see isKukaLwr
*/ */
void isKukaLwrHelp(SocketObject& client, std::string& arg)
void isKukaLwrHelp(SocketObject& client)
{ {
// unused
(void) arg;
// set up the string buffers // set up the string buffers
std::string out = ""; std::string out = "";
// assemble the help text for the client
out += "Returns \"true if the server is handling with a Kuka LWR Robot\n";
out += "\"false\" otherwise \n";
// send message to client // send message to client
client.Send(out); client.Send(out);
} }
Loading…
Cancel
Save