Skip to content

Commit

Permalink
Merge pull request #48 from sonelu/robot-manager
Browse files Browse the repository at this point in the history
JointManager, and Move classes
  • Loading branch information
sonelu authored May 19, 2020
2 parents 0e30b51 + 974b533 commit 1bfd33d
Show file tree
Hide file tree
Showing 10 changed files with 973 additions and 54 deletions.
73 changes: 73 additions & 0 deletions roboglia/base/joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,28 @@ def desired_position(self):
value += self.__offset
return value

@property
def value(self):
"""Generic accessor / setter that uses tuples to interact with the
joint. For position only joints it is a tuple with one element.
"""
return (self.position,)

@value.setter
def value(self, values):
"""``values`` should be a tuple in all circumstances. For position
only joints is a tuple with one element.
"""
pos = values[0]
if pos is not None:
self.position = pos

def desired(self):
"""Generic accessor for desired joint values. Always a tuple. For
position only joints is a tuple with one element.
"""
return (self.desired_position, )

def __repr__(self):
return f'{self.name}: p={self.position:.3f}'

Expand Down Expand Up @@ -285,6 +307,32 @@ def desired_velocity(self):
# should be absolute only
return self.__vel_w.value

@property
def value(self):
"""For a PV joint the value is a tuple with 2 values: (position,
velocity)."""
return (self.position, self.velocity)

@value.setter
def value(self, values):
"""For a PV joint the value is a tuple with 2 values.
Parameters
----------
values: tuple (position, velocity)
"""
pos = values[0]
vel = values[1]
if pos is not None:
self.position = pos
if vel is not None:
self.velocity = vel

def desired(self):
"""For PV joint the desired is a tuple of 2 values.
"""
return (self.desired_position, self.desired_velocity)

def __repr__(self):
return f'{Joint.__repr__(self)}, v={self.velocity:.3f}'

Expand Down Expand Up @@ -350,5 +398,30 @@ def desired_load(self):
# should be absolute value!
return self.__load_w.value

@property
def value(self):
"""For a PVL joint the value is a tuple of 3 values (position,
velocity, load)
"""
return (self.position, self.velocity, self.load)

@value.setter
def value(self, values):
"""For a PVL joint the value is a tuple of 3 values.
Parameters
----------
values: tuple (position, velocity, load)
"""
pos = values[0]
vel = values[1]
load = values[2]
if pos is not None:
self.position = pos
if vel is not None:
self.velocity = vel
if load is not None:
self.load = load

def __repr__(self):
return f'{JointPV.__repr__(self)}, l={self.load:.3f}'
Loading

0 comments on commit 1bfd33d

Please sign in to comment.