Hello,
I make a primitive that use the method goto:
import time
import sys
import os
import pypot.primitive
from random import randint
import math
import numpy as np
class MoveToPosition(pypot.primitive.Primitive):
properties = pypot.primitive.Primitive.properties + ['position_to_go']
def __init__(self, robot, coord='[0.0,0.0,0.0,0.0]'):
pypot.primitive.Primitive.__init__(self, robot)
self._coord = coord
self._robot = robot
def start(self):
pypot.primitive.Primitive.start(self)
def run(self):
ergo = self._robot
coord = str(self._coord)
coord = coord[1:len(coord) - 1]
c = ','
a = [pos for pos, char in enumerate(coord) if char == c]
print a
coord_x = coord[0:a[0]]
coord_y = coord[a[0] + 1:a[1]]
coord_z = coord[a[1] + 1:a[2]]
time = coord[a[2] + 1:len(coord)]
print 'Coordonnées X : ' + coord_x
print 'Coordonnées Y : ' + coord_y
print 'Coordonnées Z : ' + coord_z
print 'Durée (s) : ' + time
# Position(in meters)
pos = 0.1 * \
np.asarray([float(coord_x), float(coord_y), float(coord_z)])
print pos
# set actived mask (m4 to False)
robot.chain.active_links_mask = array(
[False, True, True, True, False, True, True, False], dtype=bool)
# function definition :goto(self, position, duration, wait=False,
# accurate=False)
ergo.chain.goto(pos, float(time), True, True)
@property
def position_to_go(self):
return self._coord
@position_to_go.setter
def position_to_go(self, coord):
print "Nouvelles coordonees : " + coord
self._coord = coord
I don’t want the motor m4 to move, so I set the active_links_mask:
#set actived mask (m4 to False)
robot.chain.active_links_mask = array([False, True, True, True, False, True, True, False], dtype=bool)
But now, when I call the primitive with start, it do nothing and loop.