From 4172cad2d4d230221a6d20955fed9db9c2f8bd8e Mon Sep 17 00:00:00 2001 From: Ali Emre Karatopuk Date: Sun, 2 Apr 2023 22:32:52 +0300 Subject: [PATCH] add two arms to python --- examples_py/arm_python_interface.cpp | 9 +++++++++ examples_py/example_highcmd.py | 4 ++++ examples_py/example_model.py | 6 ++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/examples_py/arm_python_interface.cpp b/examples_py/arm_python_interface.cpp index af91607..4c3ed92 100644 --- a/examples_py/arm_python_interface.cpp +++ b/examples_py/arm_python_interface.cpp @@ -40,8 +40,17 @@ PYBIND11_MODULE(unitree_arm_interface, m){ .def("getQTau", &LowlevelState::getTau, rvp::reference_internal) ; + py::class_(m, "UDPPort") + .def(py::init(), + py::arg("IP") = "127.0.0.1", + py::arg("toPort") = 8071, + py::arg("ownPort") = 8072 + ) + ; + py::class_(m, "CtrlComponents") .def_readwrite("armModel", &CtrlComponents::armModel) + .def_readwrite("udp", &CtrlComponents::udp) .def_readonly("dt", &CtrlComponents::dt) ; diff --git a/examples_py/example_highcmd.py b/examples_py/example_highcmd.py index 06c9a60..d8b6ad5 100644 --- a/examples_py/example_highcmd.py +++ b/examples_py/example_highcmd.py @@ -8,6 +8,10 @@ print("Press ctrl+\ to quit process.") np.set_printoptions(precision=3, suppress=True) arm = unitree_arm_interface.ArmInterface(hasGripper=True) +ctrlComp = arm._ctrlComp +udp = unitree_arm_interface.UDPPort(IP = "127.0.0.1", toPort=8071, ownPort=8072) +ctrlComp.udp = udp + armState = unitree_arm_interface.ArmFSMState arm.loopOn() diff --git a/examples_py/example_model.py b/examples_py/example_model.py index 7478a39..c5604cb 100644 --- a/examples_py/example_model.py +++ b/examples_py/example_model.py @@ -4,8 +4,10 @@ import unitree_arm_interface import numpy as np np.set_printoptions(precision=3, suppress=True) -arm = unitree_arm_interface.ArmInterface(hasGripper = True) -armModel = arm._ctrlComp.armModel +arm = unitree_arm_interface.ArmInterface(hasGripper=True) +ctrlComp = arm._ctrlComp +udp = unitree_arm_interface.UDPPort(IP = "127.0.0.1", toPort=8071, ownPort=8072) +ctrlComp.udp = udp print('--------------------------FK & IK------------------------') q_FORWARD = np.array([0, 1.5, -1, 0.54, 0, 0])