IsaacLab最新2025教程(7)-引入IK solver控制机器人

机器人控制可以直接给定关节角进行驱动实现功能,完成任务,但是关节角不是很直观而且做teleoperation或者是结合VLA模型时候,用eef pose会更符合直觉一些,isaacsim用的是LulaKinematics,因为IsaacLab现在是ETHZ的团队在开发,所以他们倾向于differentialIK和OSC(operational space controller),最新版本的IsaacLab也更新了DifferentialIKController的包,终于不用自己照着isaacgym重新写包了,官方连接在这里:

Using a task-space controller — Isaac Lab Documentation

我把代码直接粘贴过来了,官方文档里对每个代码块都有解释,这个代码风格和direct workflow RL很像,建议亲手复现一下有助于后续开发自己的强化学习环境,后续我会更新这个文档,添加我个人开发经验进来:

# Copyright (c) 2022-2025, The Isaac Lab Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause"""
This script demonstrates how to use the differential inverse kinematics controller with the simulator.The differential IK controller can be configured in different modes. It uses the Jacobians computed by
PhysX. This helps perform parallelized computation of the inverse kinematics... code-block:: bash# Usage./isaaclab.sh -p scripts/tutorials/05_controllers/run_diff_ik.py""""""Launch Isaac Sim Simulator first."""import argparsefrom isaaclab.app import AppLauncher# add argparse arguments
parser = argparse.ArgumentParser(description="Tutorial on using the differential IK controller.")
parser.add_argument("--robot", type=str, default="franka_panda", help="Name of the robot.")
parser.add_argument("--num_envs", type=int, default=128, help="Number of environments to spawn.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app"""Rest everything follows."""import torchimport isaaclab.sim as sim_utils
from isaaclab.assets import AssetBaseCfg
from isaaclab.controllers import DifferentialIKController, DifferentialIKControllerCfg
from isaaclab.managers import SceneEntityCfg
from isaaclab.markers import VisualizationMarkers
from isaaclab.markers.config import FRAME_MARKER_CFG
from isaaclab.scene import InteractiveScene, InteractiveSceneCfg
from isaaclab.utils import configclass
from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR
from isaaclab.utils.math import subtract_frame_transforms##
# Pre-defined configs
##
from isaaclab_assets import FRANKA_PANDA_HIGH_PD_CFG, UR10_CFG  # isort:skip@configclass
class TableTopSceneCfg(InteractiveSceneCfg):"""Configuration for a cart-pole scene."""# ground planeground = AssetBaseCfg(prim_path="/World/defaultGroundPlane",spawn=sim_utils.GroundPlaneCfg(),init_state=AssetBaseCfg.InitialStateCfg(pos=(0.0, 0.0, -1.05)),)# lightsdome_light = AssetBaseCfg(prim_path="/World/Light", spawn=sim_utils.DomeLightCfg(intensity=3000.0, color=(0.75, 0.75, 0.75)))# mounttable = AssetBaseCfg(prim_path="{ENV_REGEX_NS}/Table",spawn=sim_utils.UsdFileCfg(usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/Mounts/Stand/stand_instanceable.usd", scale=(2.0, 2.0, 2.0)),)# articulationif args_cli.robot == "franka_panda":robot = FRANKA_PANDA_HIGH_PD_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")elif args_cli.robot == "ur10":robot = UR10_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")else:raise ValueError(f"Robot {args_cli.robot} is not supported. Valid: franka_panda, ur10")def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):"""Runs the simulation loop."""# Extract scene entities# note: we only do this here for readability.robot = scene["robot"]# Create controllerdiff_ik_cfg = DifferentialIKControllerCfg(command_type="pose", use_relative_mode=False, ik_method="dls")diff_ik_controller = DifferentialIKController(diff_ik_cfg, num_envs=scene.num_envs, device=sim.device)# Markersframe_marker_cfg = FRAME_MARKER_CFG.copy()frame_marker_cfg.markers["frame"].scale = (0.1, 0.1, 0.1)ee_marker = VisualizationMarkers(frame_marker_cfg.replace(prim_path="/Visuals/ee_current"))goal_marker = VisualizationMarkers(frame_marker_cfg.replace(prim_path="/Visuals/ee_goal"))# Define goals for the armee_goals = [[0.5, 0.5, 0.7, 0.707, 0, 0.707, 0],[0.5, -0.4, 0.6, 0.707, 0.707, 0.0, 0.0],[0.5, 0, 0.5, 0.0, 1.0, 0.0, 0.0],]ee_goals = torch.tensor(ee_goals, device=sim.device)# Track the given commandcurrent_goal_idx = 0# Create buffers to store actionsik_commands = torch.zeros(scene.num_envs, diff_ik_controller.action_dim, device=robot.device)ik_commands[:] = ee_goals[current_goal_idx]# Specify robot-specific parametersif args_cli.robot == "franka_panda":robot_entity_cfg = SceneEntityCfg("robot", joint_names=["panda_joint.*"], body_names=["panda_hand"])elif args_cli.robot == "ur10":robot_entity_cfg = SceneEntityCfg("robot", joint_names=[".*"], body_names=["ee_link"])else:raise ValueError(f"Robot {args_cli.robot} is not supported. Valid: franka_panda, ur10")# Resolving the scene entitiesrobot_entity_cfg.resolve(scene)# Obtain the frame index of the end-effector# For a fixed base robot, the frame index is one less than the body index. This is because# the root body is not included in the returned Jacobians.if robot.is_fixed_base:ee_jacobi_idx = robot_entity_cfg.body_ids[0] - 1else:ee_jacobi_idx = robot_entity_cfg.body_ids[0]# Define simulation steppingsim_dt = sim.get_physics_dt()count = 0# Simulation loopwhile simulation_app.is_running():# resetif count % 150 == 0:# reset timecount = 0# reset joint statejoint_pos = robot.data.default_joint_pos.clone()joint_vel = robot.data.default_joint_vel.clone()robot.write_joint_state_to_sim(joint_pos, joint_vel)robot.reset()# reset actionsik_commands[:] = ee_goals[current_goal_idx]joint_pos_des = joint_pos[:, robot_entity_cfg.joint_ids].clone()# reset controllerdiff_ik_controller.reset()diff_ik_controller.set_command(ik_commands)# change goalcurrent_goal_idx = (current_goal_idx + 1) % len(ee_goals)else:# obtain quantities from simulationjacobian = robot.root_physx_view.get_jacobians()[:, ee_jacobi_idx, :, robot_entity_cfg.joint_ids]ee_pose_w = robot.data.body_state_w[:, robot_entity_cfg.body_ids[0], 0:7]root_pose_w = robot.data.root_state_w[:, 0:7]joint_pos = robot.data.joint_pos[:, robot_entity_cfg.joint_ids]# compute frame in root frameee_pos_b, ee_quat_b = subtract_frame_transforms(root_pose_w[:, 0:3], root_pose_w[:, 3:7], ee_pose_w[:, 0:3], ee_pose_w[:, 3:7])# compute the joint commandsjoint_pos_des = diff_ik_controller.compute(ee_pos_b, ee_quat_b, jacobian, joint_pos)# apply actionsrobot.set_joint_position_target(joint_pos_des, joint_ids=robot_entity_cfg.joint_ids)scene.write_data_to_sim()# perform stepsim.step()# update sim-timecount += 1# update buffersscene.update(sim_dt)# obtain quantities from simulationee_pose_w = robot.data.body_state_w[:, robot_entity_cfg.body_ids[0], 0:7]# update marker positionsee_marker.visualize(ee_pose_w[:, 0:3], ee_pose_w[:, 3:7])goal_marker.visualize(ik_commands[:, 0:3] + scene.env_origins, ik_commands[:, 3:7])def main():"""Main function."""# Load kit helpersim_cfg = sim_utils.SimulationCfg(dt=0.01, device=args_cli.device)sim = sim_utils.SimulationContext(sim_cfg)# Set main camerasim.set_camera_view([2.5, 2.5, 2.5], [0.0, 0.0, 0.0])# Design scenescene_cfg = TableTopSceneCfg(num_envs=args_cli.num_envs, env_spacing=2.0)scene = InteractiveScene(scene_cfg)# Play the simulatorsim.reset()# Now we are ready!print("[INFO]: Setup complete...")# Run the simulatorrun_simulator(sim, scene)if __name__ == "__main__":# run the main functionmain()# close sim appsimulation_app.close()

跑一下看看效果:

##安装IsaacLab时候没有用conda搞虚拟环境用下面的代码:./isaaclab.sh -p scripts/tutorials/05_controllers/run_diff_ik.py##有虚拟环境的可以之间python运行,可以调整并行环境数量保证运行流畅
python scripts/tutorials/05_controllers/run_diff_ik.py --num_envs 16

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/43378.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Vue——常用指令总结、指令修饰符、v-model原理、computed计算属性、watch监听器、ref和$refs

文章目录 一、概念理解二、指令1. 常用内置指令总结2. 常用指令修饰符3. 自定义指令4. v-model原理表单类组件封装 三、补充1. computed计算属性2. watch监视器3. ref和$refs 一、概念理解 【事件处理函数】 事件处理函数应该写到一个跟data同级的配置项(methods&a…

求职笔试题

PDD 最长公共子序列 1143-最长公共子序列 class Solution:def longestCommonSubsequence(self, text1: str, text2: str) -> int:"""二维动态规划"""m, n len(text1), len(text2)# dp [[0]* (n1)] * (m1) 这种写法错误,m1行…

【Ragflow】6. Ragflow-plus重磅更新:增加用户后台管理系统

概述 Ragflow本身并不包含用户管理的功能,我在系列前文中,写过一个脚本,用来批量插入用户,并自动加入团队,配置默认模型设置。然而,此方式需要用户安装对应环境,对普通用户并不友好。 因此我开…

什么是贴源库

贴源库的定义与核心概念 贴源库(Operational Data Store, ODS)是数据架构中的基础层,通常作为数据仓库或数据中台的第一层,负责从业务系统直接抽取、存储原始数据,并保持与源系统的高度一致性。其核心在于“贴近源头”…

MSTP+VRRP三层架构综合实验

一、实验目的 掌握VLAN、VRRP、STP和Eth-Trunk的基本配置方法。 实现内网与外网的通信,并确保网络的高可用性和冗余性。 理解DHCP、OSPF和NAT在网络中的应用。 二、实验环境 网络拓扑:如图所示,包含两台三层交换机(SW1、SW2&a…

未来村庄智慧灯杆:点亮乡村智慧生活​

在乡村振兴与数字乡村建设的时代进程中,未来村庄智慧灯杆凭借其多功能集成与智能化特性,已成为乡村基础设施建设领域的崭新焦点,为乡村生活带来了前所未有的便利,推动着乡村生活模式的深刻变革。​ 多功能集成:一杆多能…

RedHatLinux(2025.3.22)

1、创建/www目录,在/www目录下新建name和https目录,在name和https目录下分别创建一个index.htm1文件,name下面的index.html 文件中包含当前主机的主机名,https目录下的index.htm1文件中包含当前主机的ip地址。 (1&…

第十五章:Python的Pandas库详解及常见用法

在数据分析领域,Python的Pandas库是一个不可或缺的工具。它提供了高效的数据结构和数据分析工具,使得数据处理变得简单而直观。本文将详细介绍Pandas库的基本功能、常见用法,并通过示例代码演示如何使用Pandas进行数据处理。最后,…

算法为舟 思想为楫:AI时代,创作何为?

在科技浪潮汹涌澎湃的当下,AI技术以前所未有的态势席卷各个领域,创作领域亦未能幸免。当生成式AI展现出在剧本撰写、诗歌创作、图像设计等方面的惊人能力时,人类创作者仿佛置身于文明演化的十字路口,迷茫与困惑交织,兴奋与担忧并存。在AI时代,创作究竟该何去何从?这不仅…

[Raspberry Pi]如何將看門狗(WatchDog)服務建置在樹莓派的Ubuntu作業系統中?

看門狗(WatchDog)服務常應用於連網的嵌入式邊緣設備等IOT裝置和實體伺服器,主要是若這些連網裝置分散在各個應用環境中執行對應任務,例如感測物理數據,監控影像數據或執行各式Docker服務,當連網裝置因故異常,同時又處於…

Linux进程状态补充(10)

文章目录 前言一、阻塞二、挂起三、运行R四、休眠D五、四个重要概念总结 前言 上篇内容大家看的云里雾里,这实在是正常不过,因为例如 写实拷贝 等一些概念的深层原理我还没有讲解,大家不用紧张,我们继续往下学习就行!&…

RPCGC阅读

24年的MM 创新 现有点云压缩工作主要集中在保真度优化上。 而在实际应用中,压缩的目的是促进机器分析。例如,在自动驾驶中,有损压缩会显着丢失户外场景的详细信息。在三维重建中,压缩过程也会导致场景数据中语义信息(Contour)的…

keil中文注释出现乱码怎么解决

keil中文注释出现乱码怎么解决 在keil–edit–configuration中encoding改为chinese-GB2312

Linux的进程优先级调度学习笔记

Linux的进程优先级数值范围 范围 -20 到 19&#xff0c;数值越大优先级越低 示例代码 下面是一个简单的 C 语言示例&#xff0c;它演示了如何在 Linux 下修改进程的优先级并观察调度影响。 #include <stdio.h> #include <stdlib.h> #include <unistd.h> …

YOLOv8+ Deepsort+Pyqt5车速检测系统

该系统通过YOLOv8进行高效的目标检测与分割&#xff0c;结合DeepSORT算法完成目标的实时跟踪&#xff0c;并利用GPU加速技术提升处理速度。系统支持模块化设计&#xff0c;可导入其他权重文件以适应不同场景需求&#xff0c;同时提供自定义配置选项&#xff0c;如显示标签和保存…

权限提升—Windows权限提升进程注入令牌窃取服务启动

前言 依旧是提权的内容啦&#xff0c;上次讲的是利用漏洞来进行提权&#xff0c;今天我们主要讲的是利用Windows中的服务、进程等东西进行权限提升。 服务启动 首先要知道一点&#xff0c;就是windows中服务是以system权限运行的&#xff0c;假如我们创建一个运行后门的服务…

数据结构与算法——顺序表之手撕OJ题

文章目录 一、前言二、拿捏OJ题2.1移除元素2.2删除有序数组中的重复项2.3合并两个有序数组 三、总结 一、前言 Do you study today?up在上一次已经讲解完毕了有关顺序表的所有知识&#xff0c;不知道大家是否已经沉淀完毕了呢&#xff1f;有一句老话说得好啊——光看不练假把…

如何在 AI 搜索引擎(GEO)霸屏曝光,快速提升知名度?

虽然大多数人仍然使用 Google 来寻找答案&#xff0c;但正在发生快速转变。ChatGPT、Copilot、Perplexity 和 DeepSeek 等 LLM 已成为主流。这主要是因为每个都有自己的免费和公共版本&#xff0c;并且总是有重大的质量改进。 许多人每天都使用这些工具来提问和搜索互联网&…

4.训练篇2-毕设篇

resnet # 1. 从 torchvision 中加载预训练的 ResNet18 模型 # pretrainedTrue 表示使用在 ImageNet 上预训练过的参数&#xff0c;学习效果更好 base_model_resnet18 models.resnet18(pretrainedTrue)# 2. 获取 ResNet18 模型中全连接层&#xff08;fc&#xff09;的输入特征…

电磁兼容EMC概述

最近重新学了下电磁兼容&#xff0c;对这个东西更清晰了一些&#xff0c;就重新写了一篇&#xff0c;有不足的地方欢迎的大家在评论区里和我交流。 电磁兼容 电磁兼容指的是什么呢&#xff1f;指的是设备在其电磁环境中性能不受降级地正常运行并不对其他设备造成无法承受的电…