Skip to content
Snippets Groups Projects
task.py 795 B
Newer Older
import time
Guilhem Saurel's avatar
Guilhem Saurel committed

import numpy as np
Guilhem Saurel's avatar
Guilhem Saurel committed

import pinocchio as pin
import example_robot_data as robex

Guilhem Saurel's avatar
Guilhem Saurel committed

class TaskParameters:
    '''Common information to all tasks, to be allocated by each minion and the boss. '''
    robotname = 'ur5'
    robot = robex.load(robotname)
Guilhem Saurel's avatar
Guilhem Saurel committed

Guilhem Saurel's avatar
Guilhem Saurel committed
    def __init__(self, identifier, q, v, a):
        self.identifier = identifier

        self.q = q.copy()
        self.v = v.copy()
        self.a = a.copy()

        self.tau = np.zeros(self.a.shape)
        self.time = 0

    def work(self):
        start = time.perf_counter()

Guilhem Saurel's avatar
Guilhem Saurel committed
        for i in range(1_000_000):
            pin.rnea(TaskParameters.robot.model, TaskParameters.robot.data, self.q, self.v, self.a)
        self.tau[:] = TaskParameters.robot.data.tau

        self.time = time.perf_counter() - start