本文整理汇总了Python中pybullet.resetBaseVelocity方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.resetBaseVelocity方法的具体用法?Python pybullet.resetBaseVelocity怎么用?Python pybullet.resetBaseVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybullet
的用法示例。
在下文中一共展示了pybullet.resetBaseVelocity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rolling_friction
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBaseVelocity [as 别名]
def test_rolling_friction(self):
import pybullet as p
p.connect(p.DIRECT)
p.loadURDF("plane.urdf")
sphere = p.loadURDF("sphere2.urdf",[0,0,1])
p.resetBaseVelocity(sphere,linearVelocity=[1,0,0])
p.changeDynamics(sphere,-1,linearDamping=0,angularDamping=0)
#p.changeDynamics(sphere,-1,rollingFriction=0)
p.setGravity(0,0,-10)
for i in range (1000):
p.stepSimulation()
vel = p.getBaseVelocity(sphere)
self.assertLess(vel[0][0],1e-10)
self.assertLess(vel[0][1],1e-10)
self.assertLess(vel[0][2],1e-10)
self.assertLess(vel[1][0],1e-10)
self.assertLess(vel[1][1],1e-10)
self.assertLess(vel[1][2],1e-10)
p.disconnect()
示例2: _endProcess
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBaseVelocity [as 别名]
def _endProcess(self):
"""
INTERNAL METHOD, stop the robot movement.
"""
# Change the constraint to the actual position and orientation in
# order to stop the robot's motion. The force applied is purposely huge
# to avoid oscillations.
actual_pos, actual_orn = pybullet.getBasePositionAndOrientation(
self.robot_model,
physicsClientId=self.physics_client)
pybullet.changeConstraint(
self.motion_constraint,
actual_pos,
jointChildFrameOrientation=actual_orn,
maxForce=self.force * 10,
physicsClientId=self.physics_client)
pybullet.resetBaseVelocity(
self.robot_model,
[0, 0, 0],
[0, 0, 0],
physicsClientId=self.physics_client)
示例3: set_body_linvel
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBaseVelocity [as 别名]
def set_body_linvel(body, linvel):
p.resetBaseVelocity(body, linearVelocity=list(linvel))
示例4: set_body_angvel
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBaseVelocity [as 别名]
def set_body_angvel(body):
p.resetBaseVelocity(body, angularVelocity=list(angvel))
示例5: apply_action
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBaseVelocity [as 别名]
def apply_action(self, action):
if self.is_discrete:
realaction = self.action_list[action]
else:
realaction = action
p.setGravity(0, 0, 0)
p.resetBaseVelocity(self.robot_ids[0], realaction[:3], realaction[3:])
示例6: move
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBaseVelocity [as 别名]
def move(self, x, y, theta):
"""
Apply a speed on the robot's base.
Parameters:
x - Speed on the x axis, in m/s
y - Speed on the y axis, in m/s
theta - Rotational speed around the z axis, in rad/s
"""
# Kill any previous moveTo process running
self.moveTo(0, 0, 0, frame=BaseController.FRAME_ROBOT, _async=True)
# Bound the velocity. The max acceleration is not taken into account
# here, this is a potential improvment
if abs(x) > PepperBaseController.MAX_LINEAR_VELOCITY:
x = PepperBaseController.MAX_LINEAR_VELOCITY * (x/abs(x))
if abs(y) > PepperBaseController.MAX_LINEAR_VELOCITY:
y = PepperBaseController.MAX_LINEAR_VELOCITY * (y/abs(y))
if abs(theta) > PepperBaseController.MAX_ANGULAR_VELOCITY:
theta = PepperBaseController.MAX_ANGULAR_VELOCITY *\
(theta/abs(theta))
actual_pos, actual_orn = pybullet.getBasePositionAndOrientation(
self.robot_model,
physicsClientId=self.physics_client)
# convert actual_orn into euler
actual_orn = pybullet.getEulerFromQuaternion(actual_orn)
linear_world_velocity = [
x * math.cos(actual_orn[2]) - y * math.sin(actual_orn[2]),
x * math.sin(actual_orn[2]) + y * math.cos(actual_orn[2]),
0]
time.sleep(0.02)
pybullet.resetBaseVelocity(
self.robot_model,
linear_world_velocity,
[0, 0, theta],
physicsClientId=self.physics_client)