def generate_random_forward_kinematics_data()

in differentiable_robot_model/data_utils.py [0:0]


def generate_random_forward_kinematics_data(robot_model, n_data, ee_name):
    device = robot_model._device

    limits_per_joint = robot_model.get_joint_limits()
    ndof = robot_model._n_dofs
    joint_lower_bounds = np.asarray([joint["lower"] for joint in limits_per_joint])
    joint_upper_bounds = np.asarray([joint["upper"] for joint in limits_per_joint])
    q = torch.tensor(
        np.random.uniform(
            low=joint_lower_bounds, high=joint_upper_bounds, size=(n_data, ndof)
        ),
        dtype=torch.float32,
        device=device,
    )

    q = q.to(device)
    ee_pos, _ = robot_model.compute_forward_kinematics(q=q, link_name=ee_name)

    return {"q": q, "ee_pos": ee_pos}