add two arms to python

This commit is contained in:
Ali Emre Karatopuk 2023-04-02 22:32:52 +03:00
parent 155b0473d3
commit 4172cad2d4
3 changed files with 17 additions and 2 deletions

View File

@ -40,8 +40,17 @@ PYBIND11_MODULE(unitree_arm_interface, m){
.def("getQTau", &LowlevelState::getTau, rvp::reference_internal)
;
py::class_<UDPPort>(m, "UDPPort")
.def(py::init<std::string, uint, uint>(),
py::arg("IP") = "127.0.0.1",
py::arg("toPort") = 8071,
py::arg("ownPort") = 8072
)
;
py::class_<CtrlComponents>(m, "CtrlComponents")
.def_readwrite("armModel", &CtrlComponents::armModel)
.def_readwrite("udp", &CtrlComponents::udp)
.def_readonly("dt", &CtrlComponents::dt)
;

View File

@ -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()

View File

@ -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])