-
Notifications
You must be signed in to change notification settings - Fork 0
/
motor.py
26 lines (21 loc) · 813 Bytes
/
motor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import pyrosim_modded.pyrosim_modded as pyrosim
import pybullet as pblt
from datetime import datetime
import constants as c
class Motor:
def __init__(self, joint_name):
self.joint_name = joint_name
self.max_force = 25
def set_value(self, robot, desired_angle):
pyrosim.Set_Motor_For_Joint(
bodyIndex= robot.id,
jointName= self.joint_name,
controlMode= pblt.POSITION_CONTROL,
targetPosition= desired_angle * c.motor_joint_range,
maxForce= self.max_force
)
def save_values(self):
with open("./data/{}_sensor_{}.npy".format(datetime.now().strftime('%Y%m%d_%H%M'), self.joint_name), 'wb') as f:
np.save(f, self.values)
f.close()