Defines | Functions | Variables
kni_wrapper.cpp File Reference
#include <iostream>
#include <memory>
#include <math.h>
#include <vector>
#include <string.h>
#include <map>
#include "kni_wrapper/kni_wrapper.h"
#include <sstream>
Include dependency graph for kni_wrapper.cpp:

Go to the source code of this file.

Defines

#define EXPORT_FCNS

Functions

DLLEXPORT int allMotorsOff ()
DLLEXPORT int allMotorsOn ()
DLLEXPORT int calibrate (int axis)
DLLEXPORT int clearMoveBuffers ()
 clears the movebuffers
DLLEXPORT int closeGripper ()
DLLEXPORT int deleteMovementFromStack (char *name, int index)
DLLEXPORT int deleteMovementStack (char *name)
 deletes a movemnt stack
DLLEXPORT int executeConnectedMovement (struct TMovement *movement, struct TPos *startPos, bool first, bool last)
DLLEXPORT int executeMovement (struct TMovement *movement)
DLLEXPORT int flushMoveBuffers ()
 flush all the movebuffers
int getAxisFirmwareVersion (int axis, char value[])
 gets the axis firmware version and returns it in the value argument
DLLEXPORT int getCurrentControllerType (int axis)
int getDrive (int axis, int &value)
int getEncoder (int axis, int &value)
DLLEXPORT int getForce (int axis)
 set the current force
DLLEXPORT int getNumberOfMotors ()
 returns the number of motors configured
DLLEXPORT int getPosition (struct TPos *pos)
 gets a position
int getVelocity (int axis, int &value)
int getVersion (char value[])
 gets the controlboard firmware version and returns it in the value argument
DLLEXPORT int initKatana (char *configFile, char *ipaddress)
 This initializes the Katana (communication etc)
int IO_readInput (int inputNr, int &value)
DLLEXPORT int IO_setOutput (char output, int value)
int ModBusTCP_readWord (int address, int &value)
 reads a value from the register 'address' (if not connected, connect to the IP in katana.conf)
DLLEXPORT int ModBusTCP_writeWord (int address, int value)
DLLEXPORT int motorOff (int axis)
DLLEXPORT int motorOn (int axis)
DLLEXPORT int moveMot (int axis, int enc, int speed, int accel)
DLLEXPORT int moveMotAndWait (int axis, int targetpos, int tolerance)
DLLEXPORT int moveToPos (struct TPos *pos, int velocity, int acceleration)
 moves in IK
DLLEXPORT int moveToPosEnc (int enc1, int enc2, int enc3, int enc4, int enc5, int enc6, int velocity, int acceleration, int tolerance, bool _wait)
DLLEXPORT int moveToPosLin (struct TPos *targetPos, int velocity, int acceleration)
 moves in LM
DLLEXPORT int openGripper ()
DLLEXPORT int ping (int axis)
DLLEXPORT int pushMovementToStack (struct TMovement *movement, char *name)
DLLEXPORT int runThroughMovementStack (char *name, int loops)
DLLEXPORT int sendSplineToMotor (int axis, int targetpos, int duration, int p0, int p1, int p2, int p3)
DLLEXPORT int setCollisionDetection (int axis, bool state)
DLLEXPORT int setCollisionParameters (int axis, int position, int velocity)
DLLEXPORT int setControllerParameters (int axis, int ki, int kspeed, int kpos)
DLLEXPORT int setForceLimit (int axis, int limit)
DLLEXPORT int setGripper (bool hasGripper)
DLLEXPORT int setMaxAccel (int axis, int acceleration)
DLLEXPORT int setMaxVelocity (int axis, int vel)
DLLEXPORT int setPositionCollisionLimit (int axis, int limit)
DLLEXPORT int setVelocityCollisionLimit (int axis, int limit)
DLLEXPORT int startSplineMovement (int contd, int exactflag)
DLLEXPORT int unblock ()
 unblocks the robot after collision/instantstop
DLLEXPORT int waitForMot (int axis, int targetpos, int tolerance)

Variables

byte buffer [256]
static std::auto_ptr< CCdlSocketdevice
std::vector< int > encoders
static std::auto_ptr< CLMBasekatana
std::map< std::string,
std::vector< TMovement > > 
movements
int numberOfMotors
byte packet [32]
static std::auto_ptr
< CCplSerialCRC
protocol
byte size = 0

Define Documentation

#define EXPORT_FCNS

Definition at line 15 of file kni_wrapper.cpp.


Function Documentation

Switches all axes off

Returns:
returns -1 on failure, 1 if successful

Definition at line 149 of file kni_wrapper.cpp.

Put all axes into hold state

Returns:
returns -1 on failure, 1 if successful

Definition at line 163 of file kni_wrapper.cpp.

DLLEXPORT int calibrate ( int  axis)

closes the Katana session

Returns:
returns -1 on failure, 1 if successful

Definition at line 63 of file kni_wrapper.cpp.

clears the movebuffers

Definition at line 655 of file kni_wrapper.cpp.

closes the gripper if available

Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 195 of file kni_wrapper.cpp.

DLLEXPORT int deleteMovementFromStack ( char *  name,
int  index 
)

deletes a movement from the stack

Parameters:
namethe name of the stack
indexthe index of the movement to delete

Definition at line 359 of file kni_wrapper.cpp.

DLLEXPORT int deleteMovementStack ( char *  name)

deletes a movemnt stack

Definition at line 396 of file kni_wrapper.cpp.

DLLEXPORT int executeConnectedMovement ( struct TMovement movement,
struct TPos startPos,
bool  first,
bool  last 
)

execute a connected movement

Parameters:
movementa TMovement struct to execute
startPosa TPos struct with the start position, can be omitted if first=true
firstif this is the first of the connected movements (start at current pos)
lastif this is the last of the connected movements (wait for end of move)

Definition at line 496 of file kni_wrapper.cpp.

DLLEXPORT int executeMovement ( struct TMovement movement)

execute a movement

Parameters:
movementa TMovement struct to execute, starting from the current position

Definition at line 482 of file kni_wrapper.cpp.

flush all the movebuffers

Definition at line 281 of file kni_wrapper.cpp.

int getAxisFirmwareVersion ( int  axis,
char  value[] 
)

gets the axis firmware version and returns it in the value argument

Definition at line 719 of file kni_wrapper.cpp.

set the current controller limit

Returns:
0 for position controller, 1 for current controller

Definition at line 855 of file kni_wrapper.cpp.

int getDrive ( int  axis,
int &  value 
)

gets the pwm and returns it in the value argument

Parameters:
axisThe axis to send the command to
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 688 of file kni_wrapper.cpp.

int getEncoder ( int  axis,
int &  value 
)

gets the position and returns it in the value argument

Parameters:
axisThe axis to send the command to
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 704 of file kni_wrapper.cpp.

DLLEXPORT int getForce ( int  axis)

set the current force

Definition at line 842 of file kni_wrapper.cpp.

returns the number of motors configured

Definition at line 940 of file kni_wrapper.cpp.

DLLEXPORT int getPosition ( struct TPos pos)

gets a position

Definition at line 295 of file kni_wrapper.cpp.

int getVelocity ( int  axis,
int &  value 
)

gets the velocity and returns it in the value argument

Parameters:
axisThe axis to send the command to
Returns:
returns -1 on failure, 1 if successful

Definition at line 672 of file kni_wrapper.cpp.

int getVersion ( char  value[])

gets the controlboard firmware version and returns it in the value argument

Definition at line 744 of file kni_wrapper.cpp.

DLLEXPORT int initKatana ( char *  configFile,
char *  ipaddress 
)

This initializes the Katana (communication etc)

Definition at line 39 of file kni_wrapper.cpp.

int IO_readInput ( int  inputNr,
int &  value 
)

reads an input from the digital I/O and returns it in the value argument

Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 621 of file kni_wrapper.cpp.

DLLEXPORT int IO_setOutput ( char  output,
int  value 
)

sets an output of the digital I/Os

Parameters:
ouputNr1, or 2 for OutA or OutB
Returns:
returns -1 on failure, 1 if successful

Definition at line 596 of file kni_wrapper.cpp.

int ModBusTCP_readWord ( int  address,
int &  value 
)

reads a value from the register 'address' (if not connected, connect to the IP in katana.conf)

Returns:
returns -1 on failure, the read value if successful

Definition at line 570 of file kni_wrapper.cpp.

DLLEXPORT int ModBusTCP_writeWord ( int  address,
int  value 
)

writes a value to the register 'address' (if not connected, connect to the IP in katana.conf)

Returns:
returns -1 on failure, 1 if successful

Definition at line 546 of file kni_wrapper.cpp.

DLLEXPORT int motorOff ( int  axis)

Switches an axis off

Parameters:
axisThe axis to send the command to
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 135 of file kni_wrapper.cpp.

DLLEXPORT int motorOn ( int  axis)

Switches an axis on

Parameters:
axisThe axis to send the command to
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 121 of file kni_wrapper.cpp.

DLLEXPORT int moveMot ( int  axis,
int  enc,
int  speed,
int  accel 
)

PTP movement

Parameters:
axisThe axis to send the command to
encthe target position
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 77 of file kni_wrapper.cpp.

DLLEXPORT int moveMotAndWait ( int  axis,
int  targetpos,
int  tolerance 
)

calls MoveMot() and WaitForMot()

Parameters:
axisThe axis to send the command to
tolerancein encoder values (0 means wait until reached)
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, ERR_RANGE_MISMATCH if the target position is out of range 1 if successful

Definition at line 106 of file kni_wrapper.cpp.

DLLEXPORT int moveToPos ( struct TPos pos,
int  velocity,
int  acceleration 
)

moves in IK

Definition at line 309 of file kni_wrapper.cpp.

DLLEXPORT int moveToPosEnc ( int  enc1,
int  enc2,
int  enc3,
int  enc4,
int  enc5,
int  enc6,
int  velocity,
int  acceleration,
int  tolerance,
bool  _wait 
)

Moves all axes to a target encoder value

Parameters:
enc(encX) the target positions
tolerancein encoders. sent unscaled to axis and handled there. WaitForMot (and MoveMOtAndWait) checks the tolerance though.
waitwait for the movement to finish
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 223 of file kni_wrapper.cpp.

DLLEXPORT int moveToPosLin ( struct TPos targetPos,
int  velocity,
int  acceleration 
)

moves in LM

Definition at line 325 of file kni_wrapper.cpp.

opens the gripper if available

Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 209 of file kni_wrapper.cpp.

DLLEXPORT int ping ( int  axis)

checks the alive state of an axis

Parameters:
axis0 = get all axes
Returns:
If axis 0: 1 if all axes are present, negative value is the inverted number of the first axis found failing, 0 if no data is available. If axis != 0: 1 if heartbeat found, -1 if failed, 0 if no data is available.

Definition at line 954 of file kni_wrapper.cpp.

DLLEXPORT int pushMovementToStack ( struct TMovement movement,
char *  name 
)

pushes a movement onto a stack

Parameters:
movementa movement structure filled with position and movement parameters
namethe name of the stack to push it onto

Definition at line 341 of file kni_wrapper.cpp.

DLLEXPORT int runThroughMovementStack ( char *  name,
int  loops 
)

Runs through the movement stack, executes the movements

Parameters:
namethe name of the stack to run through
loopsthe number of loops to run

Definition at line 426 of file kni_wrapper.cpp.

DLLEXPORT int sendSplineToMotor ( int  axis,
int  targetpos,
int  duration,
int  p0,
int  p1,
int  p2,
int  p3 
)

sends a single polynomial to an axis (G)

Parameters:
axisThe axis to send the command to
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, ERR_RANGE_MISMATCH if the target position is out of range 1 if successful

Definition at line 252 of file kni_wrapper.cpp.

DLLEXPORT int setCollisionDetection ( int  axis,
bool  state 
)

sets the collision detection on the axes.

Parameters:
statetrue = on
axis0 = set all axes
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 768 of file kni_wrapper.cpp.

DLLEXPORT int setCollisionParameters ( int  axis,
int  position,
int  velocity 
)

sets the collision parameters this function internally calls setPositionCollisionLimit and setVelocityCollisionLimit

Parameters:
axis0 = set all axes
positionrange 1-10
velocityrange 1-10

Definition at line 813 of file kni_wrapper.cpp.

DLLEXPORT int setControllerParameters ( int  axis,
int  ki,
int  kspeed,
int  kpos 
)

sets the controller parameters

Parameters:
axis0 = set all axes
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 882 of file kni_wrapper.cpp.

DLLEXPORT int setForceLimit ( int  axis,
int  limit 
)

set the force limit

Parameters:
axis0 = all axes
limitlimit in percent

Definition at line 828 of file kni_wrapper.cpp.

DLLEXPORT int setGripper ( bool  hasGripper)

sets or unsets whether the Katana has a Gripper

Parameters:
hasGripperset to true if a gripper is present. Default at startup: false
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 177 of file kni_wrapper.cpp.

DLLEXPORT int setMaxAccel ( int  axis,
int  acceleration 
)

sets the maximum acceleration (allowed values are only 1 and 2)

Parameters:
axis0 = set all axes
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 918 of file kni_wrapper.cpp.

DLLEXPORT int setMaxVelocity ( int  axis,
int  vel 
)

sets the maximum velocity

Parameters:
axis0 = set all axes
vel1-180 are valid
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, 1 if successful

Definition at line 896 of file kni_wrapper.cpp.

DLLEXPORT int setPositionCollisionLimit ( int  axis,
int  limit 
)

set the position collision limit

Parameters:
axis0 = all axes

Definition at line 785 of file kni_wrapper.cpp.

DLLEXPORT int setVelocityCollisionLimit ( int  axis,
int  limit 
)

set the velocity collision limit

Parameters:
axis0 = all axes

Definition at line 799 of file kni_wrapper.cpp.

DLLEXPORT int startSplineMovement ( int  contd,
int  exactflag 
)

starts the linear movement (G+128)

Returns:
returns -1 on failure, 1 if successful

Definition at line 266 of file kni_wrapper.cpp.

DLLEXPORT int unblock ( )

unblocks the robot after collision/instantstop

Definition at line 868 of file kni_wrapper.cpp.

DLLEXPORT int waitForMot ( int  axis,
int  targetpos,
int  tolerance 
)

waits for a motor

Parameters:
axisThe axis to wait for
targetpos(only relevant if mode is 0)
tolerance(only relevant if mode is 0) in encoder values
Returns:
returns ERR_FAILURE on failure, ERR_INVALID_ARGUMENT if an argument is out of range, ERR_STATE_MISMATCH if the command was given to a wrong state, ERR_RANGE_MISMATCH if the target position is out of range 1 if successful

Definition at line 92 of file kni_wrapper.cpp.


Variable Documentation

byte buffer[256]

Definition at line 34 of file kni_wrapper.cpp.

std::auto_ptr<CCdlSocket> device [static]

Definition at line 23 of file kni_wrapper.cpp.

Definition at line 29 of file kni_wrapper.cpp.

std::auto_ptr<CLMBase> katana [static]

Definition at line 22 of file kni_wrapper.cpp.

std::map< std::string, std::vector<TMovement> > movements

Definition at line 27 of file kni_wrapper.cpp.

Definition at line 31 of file kni_wrapper.cpp.

byte packet[32]

Definition at line 33 of file kni_wrapper.cpp.

std::auto_ptr<CCplSerialCRC> protocol [static]

Definition at line 24 of file kni_wrapper.cpp.

byte size = 0

Definition at line 35 of file kni_wrapper.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


kni
Author(s): Neuronics AG (see AUTHORS.txt); ROS wrapper by Martin Günther
autogenerated on Tue May 28 2013 14:52:55