return [ action.grasp for action in self._action(state, num_actions=num_actions) ]
时间: 2024-05-21 08:14:19 浏览: 19
这段代码看起来是一个函数,输入参数是一个状态(state)和一个可选的动作数量(num_actions),输出是一个动作列表。这个函数内部使用了一个私有函数(self._action),通过输入的状态和可选的动作数量生成一个动作列表。在这个动作列表中,每个动作都有一个抓取属性(action.grasp)。最终的输出是一个由所有动作的抓取属性组成的列表。
相关问题
class GraspDatasetBase(torch.utils.data.Dataset): """ An abstract dataset for training GG-CNNs in a common format. """ def __init__(self, output_size=300, include_depth=True, include_rgb=False, random_rotate=False, random_zoom=False, input_only=False): """ :param output_size: Image output size in pixels (square) :param include_depth: Whether depth image is included :param include_rgb: Whether RGB image is included :param random_rotate: Whether random rotations are applied :param random_zoom: Whether random zooms are applied :param input_only: Whether to return only the network input (no labels) """ self.output_size = output_size self.random_rotate = random_rotate self.random_zoom = random_zoom self.input_only = input_only self.include_depth = include_depth self.include_rgb = include_rgb self.grasp_files = [] if include_depth is False and include_rgb is False: raise ValueError('At least one of Depth or RGB must be specified.')
这段代码是一个抽象类 GraspDatasetBase,用于在一个通用的格式中训练 GG-CNNs。该类的构造函数包含了多个参数,例如输出图像的大小、是否包括深度图像、是否包括 RGB 图像、是否进行随机旋转、是否进行随机缩放以及是否仅返回网络输入等。在该类中,还定义了一个变量 grasp_files 用于存储夹爪数据文件。如果 include_depth 和 include_rgb 均为 False,会抛出 ValueError 异常。
for grasp_point_array in local_max: grasp_point = tuple(grasp_point_array) grasp_angle = ang_img[grasp_point] g = Grasp(grasp_point, grasp_angle) if width_img is not None: g.length = width_img[grasp_point] g.width = g.length/2 grasps.append(g)
这个循环用于将局部最大值转换为实际的抓取点,并创建 `Grasp` 对象。对于每个抓取点,该代码将其转换为元组,并使用 `ang_img` 获取抓取点的角度。然后,使用 `Grasp` 构造函数创建一个新的 `Grasp` 对象,并将其添加到 `grasps` 列表中。如果提供了 Width 图像,则还会将其用于设置 `Grasp` 对象的 length 和 width 的属性。最后,该函数返回 `grasps` 列表。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)