modbus_test/robot/pallet.py

35 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pybullet as p
class Pallet:
def __init__(
self, position=[1, 1, 0], size=[0.8, 1.2, 0.144], color=[0.6, 0.3, 0.1, 0.5]
):
self.size = size
self.position = position
self.color = color
self.create_pallet()
def create_pallet(self):
half_size = [s * 0.5 for s in self.size]
# Создаем collision shape для паллеты
collision_shape = p.createCollisionShape(p.GEOM_BOX, halfExtents=half_size)
# Создаем визуальное отображение (shape) для паллеты
visual_shape = p.createVisualShape(
p.GEOM_BOX, halfExtents=half_size, rgbaColor=self.color
)
# Создаем объект паллеты в физическом мире
self.pallet_id = p.createMultiBody(
baseMass=0, # Масса 0, чтобы паллета не взаимодействовала с физикой
baseCollisionShapeIndex=collision_shape,
baseVisualShapeIndex=visual_shape,
basePosition=self.position,
)
# Устанавливаем позицию объекта паллеты в физическом мире
p.resetBasePositionAndOrientation(self.pallet_id, self.position, [0, 0, 0, 1])