start imitate

This commit is contained in:
Kseninia Mikhaylova 2024-10-25 11:29:20 +03:00
parent b1d10fe3b1
commit 233417c50b
4 changed files with 2609 additions and 14 deletions

2580
app.log

File diff suppressed because it is too large Load Diff

View File

@ -93,12 +93,12 @@ class MainContentComponent(QWidget):
super().resizeEvent(event)
def handle_value_change(self, new_value):
logger.info(f"Value changed: {new_value}")
panels = [self.imitatorPanel, self.visPanel]
for p in panels:
if new_value == "not_connected":
self.imitatorPanel.setDisabled(True)
p.setDisabled(True)
if new_value == "connected":
self.imitatorPanel.setDisabled(False)
p.setDisabled(False)
if __name__ == "__main__":

View File

@ -2,6 +2,7 @@
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QSizePolicy
from PyQt5.QtGui import QImage, QPixmap
from PyQt5.QtCore import QTimer
from logger import logger
class Visualize(QWidget):
def __init__(self, get_pybullet_image):
@ -24,6 +25,8 @@ class Visualize(QWidget):
def update_image(self):
(rgb, width, height) = self.get_pybullet_image()
# logger.info('upd img')
# Преобразование RGB-данных в QImage
image = QImage(rgb, width, height, QImage.Format_RGB888)
pixmap = QPixmap.fromImage(image)

View File

@ -1,17 +1,19 @@
import socket
import json
import os
from typing import Literal
import math
from typing import Literal
from pprint import pprint
import threading
import pybullet as p
import pybullet_data
os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
from robot.func import *
from logger import logger
os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
class SocketRobotArm:
line_speed = 100.0
@ -52,21 +54,30 @@ class SocketRobotArm:
self.socket.close()
def run_pybullet(self):
self.physics_client = p.connect(p.DIRECT)
self.physics_client = p.connect(p.GUI)
p.setGravity(0, 0, -9.81, physicsClientId=self.physics_client)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
urdf_path = os.path.join("urdf", f"{self.urdf_filename}.urdf")
if not os.path.exists(urdf_path):
raise FileNotFoundError(f"URDF file not found: {urdf_path}")
self.body_id = p.loadURDF(
f"urdf/{self.urdf_filename}.urdf",
urdf_path,
[0, 0, 0],
useFixedBase=True,
)
logger.info(f"Loaded URDF: {urdf_path} with body ID: {self.body_id}")
def get_pybullet_image(self):
p.stepSimulation()
width, height, rgb, _, _ = p.getCameraImage(
width=320,
height=240,
width=800,
height=800,
viewMatrix=p.computeViewMatrix(
cameraEyePosition=[1, 1, 1],
cameraEyePosition=[0, 0, 1],
cameraTargetPosition=[0, 0, 0],
cameraUpVector=[0, 0, 1],
),
@ -167,6 +178,7 @@ class SocketRobotArm:
print(text)
def set_joint(self, coordinates):
logger.info('set joint')
num_joints = p.getNumJoints(self.body_id)
for joint_index in range(0, num_joints):
# if not joint_index in coordinates: