Skip to content
Snippets Groups Projects
Commit 2c8a2613 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Added missing .lc file.

Complemented network packes with cookie to accommodate delayed control.
parent ec9ee822
Branches
No related tags found
No related merge requests found
/* Types and samples used in controllers */
typedef struct {
/* Control parameters: */
float parKp; /* Position control proportional gain. */
float parKv; /* Velocity control proportional gain. */
float parKi; /* Velocity control integration gain. */
float parTrqMin; /* Minimum torque (control output) allowed. */
float parTrqMax; /* Dito maximum. */
/* Exposed (measured or computed) states: */
double posRawAbs; /* Measured unfiltered motor angle. [abs] */
double posRawFb; /* Measured unfiltered motor angle. [feedback] */
double posFlt; /* Filtered motor angle. */
float velRaw; /* Unfiltered angular velocity. */
float velFlt; /* Dito filtered, also for motor shaft. */
float velOut; /* Dito according to actual velocity control ref. */
float trqRaw; /* Measured (or internal) unfiltered torque. */
float trqRefFlt; /* filtered Torque ref */
/* State references and feedforward signals (sum of torques are applied): */
double posRef; /* Nominal position reference. */
float velRef; /* Dito for the velocity reference/feedforward. */
float trqFfw; /* Model-based torque feedforward. */
float trqFfwGrav; /* total dynamic model based torque. */
} irb2ext_joint_abs;
typedef struct {
/* Possibly updated control parameters: */
float parKp;
float parKv;
float parKi;
/* Modified references and feed forward: */
double posRef;
float velRef;
float trqFfw;
} ext2irb_joint_abs;
typedef struct {
int instruction;
float value1;
float value2;
float value3;
float value4;
float value5;
float value6;
byte string1[20];
byte string2[20];
} extctrl_communication_data;
typedef struct {
int kind;
irb2ext_joint_abs joint[_];
// mocgendata.instruction != 0 when RAPID has sent data
extctrl_communication_data mocgendata;
} irb2ext_robot_abs;
typedef struct {
boolean obtaining;
boolean manualMode;
boolean controlActive;
irb2ext_robot_abs robot[_];
} irb2ext_type;
typedef struct {
ext2irb_joint_abs joint[_];
// mocgendata.instruction != 0 when data is sent to RAPID
extctrl_communication_data mocgendata;
} ext2irb_robot_abs;
typedef struct {
ext2irb_robot_abs robot[_];
} ext2irb_type;
sample irb2ext_type irb2ext;
sample ext2irb_type ext2irb;
/* Types and samples used over the network */
typedef struct {
/* Possibly updated control parameters: */
float parKp;
float parKv;
float parKi;
/* Modified references and feed forward: */
double posOffset;
float velOffset;
float trqFfwOffset;
} ext2irb_joint_offset;
typedef struct {
int kind;
irb2ext_joint_abs joint[_];
// Length of mocgendata is 1 when RAPID has sent data
extctrl_communication_data mocgendata[_];
} irb2ext_robot_net;
typedef struct {
short cookie;
boolean obtaining;
boolean manualMode;
boolean controlActive;
irb2ext_robot_net robot[_];
} irb2ext_net_type;
typedef struct {
ext2irb_joint_offset joint[_];
// Length of mocgendata is 1 when data is sent back to RAPID
extctrl_communication_data mocgendata[_];
} ext2irb_robot_net;
typedef struct {
short cookie;
ext2irb_robot_net robot[_];
} ext2irb_net_type;
typedef irb2ext_joint_abs irb2ext_joint_net;
typedef ext2irb_joint_offset ext2irb_joint_net;
typedef float force_torque_vector[6];
sample irb2ext_net_type irb2ext_net;
sample ext2irb_net_type ext2irb_net;
sample force_torque_vector force_torque_net[_];
......@@ -39,7 +39,8 @@ class Arm(extctrl2014_lc.ext2irb_robot_net):
class Robot(extctrl2014_lc.ext2irb_net):
def __init__(self, arms):
def __init__(self, cookie=0, arms=[]):
self.cookie = cookie
self.robot = arms
def __repr__(self):
......@@ -107,7 +108,8 @@ if __name__ == "__main__":
delta = -delta
offset += delta
print "ROBOT", value
feedback = Robot([ Arm(joint=[ Joint(posOffset=offset),
feedback = Robot(cookie=value.cookie,
arms=[ Arm(joint=[ Joint(posOffset=offset),
Joint(posOffset=offset*2) ],
mocgendata=[])])
encoder.encode(feedback,
......
......@@ -64,7 +64,8 @@ class Arm(extctrl2014_lc.irb2ext_robot_net):
class Robot(extctrl2014_lc.irb2ext_net):
def __init__(self, arms):
def __init__(self, cookie=0, arms=[]):
self.cookie = cookie
self.obtaining = False
self.manualMode = False
self.controlActive = False
......@@ -124,7 +125,7 @@ if __name__ == '__main__':
encoder.add_decl(extctrl2014_lc.irb2ext_net.signature)
encoder.add_decl(extctrl2014_lc.force_torque_net.signature)
robot = Robot([ Arm(kind=0,
robot = Robot(arms=[ Arm(kind=0,
joint=[ Joint(), Joint() ],
mocgendata=[])])
def run_decoder():
......@@ -145,6 +146,7 @@ if __name__ == '__main__':
t.start()
for i in range(100):
time.sleep(0.1)
robot.cookie = i
encoder.encode(robot,
extctrl2014_lc.irb2ext_net.signature)
# Let connection timeout (whenever that gets implemented)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment