This is a confusing bit of code
def ConvertFromLegModel(self, actions):
"""Convert the actions that use leg model to the real motor actions.
Args:
actions: The theta, phi of the leg model.
Returns:
The eight desired motor angles that can be used in ApplyActions().
"""
COPY THE ACTIONS.
motor_angle = copy.deepcopy(actions)
DEFINE SOME THINGS
scale_for_singularity = 1
offset_for_singularity = 1.5
half_num_motors = int(self.num_motors / 2)
quarter_pi = math.pi / 4
FOR EVERY MOTOR
for i in range(self.num_motors):
THE ACTION INDEX IS THE FLOOR OF HALF. 00112233
action_idx = int(i // 2)
WELL, SO, THE FORWARD BACKWARD COMPONENT is
negative thingy times 45 degrees times (the action of the index plus half the motors.... plus the offset thingy)
forward_backward_component = (
-scale_for_singularity * quarter_pi *
(actions[action_idx + half_num_motors] + offset_for_singularity))
AND SO THE EXTENSION COMPONENT IS either + or - 45 degrees times the action.
extension_component = (-1)**i * quarter_pi * actions[action_idx]
IF 4,5,6,7 MAKE THAT THING NEGATIVE.
if i >= half_num_motors:
extension_component = -extension_component
THE ANGLE IS... PI + thingy 1 + thingy 2.
motor_angle[i] = (math.pi + forward_backward_component + extension_component)
return motor_angle
Ok my error is,
File "/opt/gym-robotable/gym_robotable/envs/robotable_gym_env.py", line 350, in step
action = self._transform_action_to_motor_command(action)
File "/opt/gym-robotable/gym_robotable/envs/robotable_gym_env.py", line 313, in _transform_action_to_motor_command
action = self.robotable.ConvertFromLegModel(action)
AttributeError: 'Robotable' object has no attribute 'ConvertFromLegModel'
Ok anyway i debugged for an hour and now it’s doing something. it’s saving numpy files now.
policy_RobotableEnv-v0_20200516-192435.npy contains:
�NUMPYv{‘descr’: ‘<f8’, ‘fortran_order’: False, ‘shape’: (4, 16), }
Cool.
But yeah i had to comment out a lot of stuff. Seems like the actions it’s generating are mostly 0.
Since I simplified to a table, turns out I don’t need any of that ConvertFromLegModel code.
Ok anyway, i started over with minitaur. lol. why are there two tables? Changing the motorDirections gave me this. Good progress.