本文整理汇总了Python中pybullet.JOINT_REVOLUTE属性的典型用法代码示例。如果您正苦于以下问题:Python pybullet.JOINT_REVOLUTE属性的具体用法?Python pybullet.JOINT_REVOLUTE怎么用?Python pybullet.JOINT_REVOLUTE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pybullet
的用法示例。
在下文中一共展示了pybullet.JOINT_REVOLUTE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import JOINT_REVOLUTE [as 别名]
def __init__(self):
self.link = UrdfLink()
self.joint_name = "joint_dummy"
self.joint_type = p.JOINT_REVOLUTE
self.joint_lower_limit = 0
self.joint_upper_limit = -1
self.parent_name = "parentName"
self.child_name = "childName"
self.joint_origin_xyz = [1,2,3]
self.joint_origin_rpy = [1,2,3]
self.joint_axis_xyz = [1,2,3]
示例2: initialize
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import JOINT_REVOLUTE [as 别名]
def initialize(self):
self.urdfLinks=[]
self.urdfJoints=[]
self.robotName = ""
self.linkNameToIndex={}
self.jointTypeToName={p.JOINT_FIXED:"JOINT_FIXED" ,\
p.JOINT_REVOLUTE:"JOINT_REVOLUTE",\
p.JOINT_PRISMATIC:"JOINT_PRISMATIC" }
示例3: writeJoint
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import JOINT_REVOLUTE [as 别名]
def writeJoint(self, file, urdfJoint, precision=5):
jointTypeStr = "invalid"
if urdfJoint.joint_type == p.JOINT_REVOLUTE:
if urdfJoint.joint_upper_limit < urdfJoint.joint_lower_limit:
jointTypeStr = "continuous"
else:
jointTypeStr = "revolute"
if urdfJoint.joint_type == p.JOINT_FIXED:
jointTypeStr = "fixed"
if urdfJoint.joint_type == p.JOINT_PRISMATIC:
jointTypeStr = "prismatic"
str = '\t<joint name=\"{}\" type=\"{}\">\n'.format(urdfJoint.joint_name, jointTypeStr)
file.write(str)
str = '\t\t<parent link=\"{}\"/>\n'.format(urdfJoint.parent_name)
file.write(str)
str = '\t\t<child link=\"{}\"/>\n'.format(urdfJoint.child_name)
file.write(str)
if urdfJoint.joint_type == p.JOINT_PRISMATIC:
#todo: handle limits
lowerLimit=-0.5
upperLimit=0.5
str='<limit effort="1000.0" lower="{:.{prec}f}" upper="{:.{prec}f}" velocity="0.5"/>'.format(lowerLimit,upperLimit,prec=precision)
file.write(str)
file.write("\t\t<dynamics damping=\"1.0\" friction=\"0.0001\"/>\n")
str = '\t\t<origin xyz=\"{:.{prec}f} {:.{prec}f} {:.{prec}f}\"/>\n'.format(urdfJoint.joint_origin_xyz[0],\
urdfJoint.joint_origin_xyz[1],urdfJoint.joint_origin_xyz[2], prec=precision)
str = '\t\t<origin rpy=\"{:.{prec}f} {:.{prec}f} {:.{prec}f}\" xyz=\"{:.{prec}f} {:.{prec}f} {:.{prec}f}\"/>\n'.format(urdfJoint.joint_origin_rpy[0],\
urdfJoint.joint_origin_rpy[1],urdfJoint.joint_origin_rpy[2],\
urdfJoint.joint_origin_xyz[0],\
urdfJoint.joint_origin_xyz[1],urdfJoint.joint_origin_xyz[2], prec=precision)
file.write(str)
str = '\t\t<axis xyz=\"{:.{prec}f} {:.{prec}f} {:.{prec}f}\"/>\n'.format(urdfJoint.joint_axis_xyz[0],\
urdfJoint.joint_axis_xyz[1],urdfJoint.joint_axis_xyz[2], prec=precision)
file.write(str)
file.write("\t</joint>\n")
示例4: create_cstr
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import JOINT_REVOLUTE [as 别名]
def create_cstr(descr):
if descr['joint_type'] == 'revolute':
joint_type = p.JOINT_REVOLUTE
elif descr['joint_type'] == 'prismatic':
joint_type = p.JOINT_PRISMATIC
elif descr['joint_type'] == 'fixed':
joint_type = p.JOINT_FIXED
elif descr['joint_type'] == 'point2point':
joint_type = p.JOINT_POINT2POINT
else:
raise ValueError('Unrecognized joint type {}'.format(joint_type))
if (descr['parent_frame_quat'] is None) or \
(descr['child_frame_quat'] is None):
cstr = p.createConstraint(
parentBodyUniqueId=descr['parent_body'],
parentLinkIndex=descr['parent_link'],
childBodyUniqueId=descr['child_body'],
childLinkIndex=descr['child_link'],
jointType=joint_type,
jointAxis=descr['joint_axis'],
parentFramePosition=descr['parent_frame_pos'],
childFramePosition=descr['child_frame_pos'])
else:
cstr = p.createConstraint(
parentBodyUniqueId=descr['parent_body'],
parentLinkIndex=descr['parent_link'],
childBodyUniqueId=descr['child_body'],
childLinkIndex=descr['child_link'],
jointType=joint_type,
jointAxis=descr['joint_axis'],
parentFramePosition=descr['parent_frame_pos'],
childFramePosition=descr['child_frame_pos'],
parentFrameOrientation=descr['parent_frame_quat'],
childFrameOrientation=descr['child_frame_quat'])
return cstr
示例5: reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import JOINT_REVOLUTE [as 别名]
def reset(self):
# Load robot model
flags = p.URDF_ENABLE_CACHED_GRAPHICS_SHAPES | p.URDF_USE_INERTIA_FROM_FILE
self.robot_id = p.loadURDF(os.path.join(franka_panda.get_data_path(), "panda_model.urdf"),
basePosition=self._base_position, useFixedBase=True, flags=flags,
physicsClientId=self._physics_client_id)
assert self.robot_id is not None, "Failed to load the panda model"
# reset joints to home position
num_joints = p.getNumJoints(self.robot_id, physicsClientId=self._physics_client_id)
idx = 0
for i in range(num_joints):
joint_info = p.getJointInfo(self.robot_id, i, physicsClientId=self._physics_client_id)
joint_name = joint_info[1].decode("UTF-8")
joint_type = joint_info[2]
if joint_type is p.JOINT_REVOLUTE or joint_type is p.JOINT_PRISMATIC:
assert joint_name in self.initial_positions.keys()
self._joint_name_to_ids[joint_name] = i
p.resetJointState(self.robot_id, i, self.initial_positions[joint_name], physicsClientId=self._physics_client_id)
p.setJointMotorControl2(self.robot_id, i, p.POSITION_CONTROL,
targetPosition=self.initial_positions[joint_name],
positionGain=0.2, velocityGain=1.0,
physicsClientId=self._physics_client_id)
idx += 1
self.ll, self.ul, self.jr, self.rs = self.get_joint_ranges()
if self._use_IK:
self._home_hand_pose = [0.2, 0.0, 0.8,
min(m.pi, max(-m.pi, m.pi)),
min(m.pi, max(-m.pi, 0)),
min(m.pi, max(-m.pi, 0))]
self.apply_action(self._home_hand_pose)
p.stepSimulation(physicsClientId=self._physics_client_id)
示例6: joinUrdf
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import JOINT_REVOLUTE [as 别名]
def joinUrdf(self, childEditor, parentLinkIndex=0, jointPivotXYZInParent=[0,0,0], jointPivotRPYInParent=[0,0,0], jointPivotXYZInChild=[0,0,0], jointPivotRPYInChild=[0,0,0], parentPhysicsClientId=0, childPhysicsClientId=0):
childLinkIndex = len(self.urdfLinks)
insertJointIndex = len(self.urdfJoints)
#combine all links, and add a joint
for link in childEditor.urdfLinks:
self.linkNameToIndex[link.link_name]=len(self.urdfLinks)
self.urdfLinks.append(link)
for joint in childEditor.urdfJoints:
self.urdfJoints.append(joint)
#add a new joint between a particular
jointPivotQuatInChild = p.getQuaternionFromEuler(jointPivotRPYInChild)
invJointPivotXYZInChild, invJointPivotQuatInChild = p.invertTransform(jointPivotXYZInChild,jointPivotQuatInChild)
#apply this invJointPivot***InChild to all inertial, visual and collision element in the child link
#inertial
pos, orn = p.multiplyTransforms(self.urdfLinks[childLinkIndex].urdf_inertial.origin_xyz,p.getQuaternionFromEuler(self.urdfLinks[childLinkIndex].urdf_inertial.origin_rpy),invJointPivotXYZInChild,invJointPivotQuatInChild, physicsClientId=parentPhysicsClientId)
self.urdfLinks[childLinkIndex].urdf_inertial.origin_xyz = pos
self.urdfLinks[childLinkIndex].urdf_inertial.origin_rpy = p.getEulerFromQuaternion(orn)
#all visual
for v in self.urdfLinks[childLinkIndex].urdf_visual_shapes:
pos, orn = p.multiplyTransforms(v.origin_xyz,p.getQuaternionFromEuler(v.origin_rpy),invJointPivotXYZInChild,invJointPivotQuatInChild)
v.origin_xyz = pos
v.origin_rpy = p.getEulerFromQuaternion(orn)
#all collision
for c in self.urdfLinks[childLinkIndex].urdf_collision_shapes:
pos, orn = p.multiplyTransforms(c.origin_xyz,p.getQuaternionFromEuler(c.origin_rpy),invJointPivotXYZInChild,invJointPivotQuatInChild)
c.origin_xyz = pos
c.origin_rpy = p.getEulerFromQuaternion(orn)
childLink = self.urdfLinks[childLinkIndex]
parentLink = self.urdfLinks[parentLinkIndex]
joint = UrdfJoint()
joint.link = childLink
joint.joint_name = "joint_dummy1"
joint.joint_type = p.JOINT_REVOLUTE
joint.joint_lower_limit = 0
joint.joint_upper_limit = -1
joint.parent_name = parentLink.link_name
joint.child_name = childLink.link_name
joint.joint_origin_xyz = jointPivotXYZInParent
joint.joint_origin_rpy = jointPivotRPYInParent
joint.joint_axis_xyz = [0,0,1]
#the following commented line would crash PyBullet, it messes up the joint indexing/ordering
#self.urdfJoints.append(joint)
#so make sure to insert the joint in the right place, to links/joints match
self.urdfJoints.insert(insertJointIndex,joint)
return joint
示例7: loadRobot
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import JOINT_REVOLUTE [as 别名]
def loadRobot(self, translation, quaternion, physicsClientId=0):
"""
Loads the robot into a simulation, loads the joints and the links
descriptions. The joints are set to 0 rad.
Parameters:
translation - List containing 3 elements, the translation [x, y, z]
of the robot in the WORLD frame
quaternion - List containing 4 elements, the quaternion
[x, y, z, q] of the robot in the WORLD frame
physicsClientId - The id of the simulated instance in which the
robot is supposed to be loaded
Returns:
boolean - True if the method ran correctly, False otherwise
"""
try:
self.physics_client = physicsClientId
self.robot_model = pybullet.loadURDF(
self.description_file,
translation,
quaternion,
useFixedBase=False,
globalScaling=1.0,
physicsClientId=self.physics_client,
flags=pybullet.URDF_USE_SELF_COLLISION |
pybullet.URDF_USE_MATERIAL_COLORS_FROM_MTL)
except pybullet.error as e:
raise pybullet.error("Cannot load robot model: " + str(e))
for i in range(pybullet.getNumJoints(
self.robot_model,
physicsClientId=self.physics_client)):
if IS_VERSION_PYTHON_3:
# PYTHON 3 version needs a conversion bytes to str
joint_info = pybullet.getJointInfo(
self.robot_model,
i,
physicsClientId=self.physics_client)
self.link_dict[joint_info[12].decode('utf-8')] =\
Link(joint_info)
if joint_info[2] == pybullet.JOINT_PRISMATIC or\
joint_info[2] == pybullet.JOINT_REVOLUTE:
self.joint_dict[joint_info[1].decode('utf-8')] =\
Joint(joint_info)
else:
# PYTHON 2 Version
joint_info = pybullet.getJointInfo(
self.robot_model,
i,
physicsClientId=self.physics_client)
self.link_dict[joint_info[12]] = Link(joint_info)
if joint_info[2] == pybullet.JOINT_PRISMATIC or\
joint_info[2] == pybullet.JOINT_REVOLUTE:
self.joint_dict[joint_info[1]] = Joint(joint_info)