Package: phawd
phawd_py: Python binding for phawdphawdis a lightweight and cross-platform software based on QT5, mainly used for robot simulation, programming and debugging, which is the abbreviation of Parameter Handler And Waveform Displayer.Here is the python binding of phawd core functions, mainly contains the interface between the robot controller written in Python and phawd software.0 InstallationOn Windows10 or Linux:pipinstallphawdMacOS is not supported for now.1 Build from source1.1 PrerequisitesA compiler with C++11 support (gcc/g++ is recommended under Linux, MSVC is mandatory under Windows)CMake >= 3.14 (Make sure that you can use cmake on the command line)Pip 10+1.2 commandJust clone this repository and pip install. Note the--recursiveoption which is needed for the pybind11 submodule:gitclone--recursivehttps://github.com/HuNingHe/phawd_py.git
pipinstall./phawd_py2 Using cibuildwheelcibuildwheelused for building python wheels acrossMac, Linux, Windows, onmultiple versions of Python. The steps are as follows:pipinstallcibuildwheel
gitclone--recursivehttps://github.com/HuNingHe/phawd_py.gitcdphawd_py# on windowscibuildwheel--platformwindows# on linuxcibuildwheel--platformlinuxThen you will get 36 python wheels. For example, you can then install phawd_py by:cdwheelhouse# this depends on your system and python versionpipinstallphawd-0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl3 SharedMemory example3.1 Prerequisites in phawdphawd's yaml file is as follows:RobotName:shm_demoType:Shared MemoryWaveParamNum:3DOUBLE:p_d:3.14159S64:p_s64:31VEC3_DOUBLE:p_vec3d:[1,2,3]Read this file using phawd, and click ready button. Then run the code demo as below.3.2 code demoA robot controller program example using sharedmemory to communicate with phawd software:# robot controllerfromphawdimportSharedMemory,SharedParameters,ParameterCollection,Parameterif__name__=='__main__':num_ctr_params=3num_wave_params=3shm_size=SharedParameters.__sizeof__()+(num_ctr_params+num_wave_params)*Parameter.__sizeof__()shm=SharedMemory()shm.attach(name="shm_demo",size=shm_size)sp=shm.get()params=sp.getParameters()print('numControlParams:{}'.format(sp.numControlParams))print('numWaveParams:{}'.format(sp.numWaveParams))print('p_d name:{}; ValueKind:{}; Value:{}'.format(params[0].getName(),params[0].getValueKind(),params[0].getDouble()))print('p_s64 name:{}; ValueKind:{}; Value:{}'.format(params[1].getName(),params[1].getValueKind(),params[1].getS64()))print('p_vec3d name:{}; ValueKind:{}; Value:{}'.format(params[2].getName(),params[2].getValueKind(),params[2].getVec3d()))pw0=Parameter("pw0",5)pw1=Parameter("pw1",3.14)pw2=Parameter("pw2",[1,2,3])sp.setParameters([pw0,pw1,pw2])sp.connected+=1# This is important, otherwise phawd will not be able to detect the writing of data# If you have a lot of parameters, and it is inconvenient to process by index, you may wish to try ParameterCollectionpc=ParameterCollection()sp.collectParameters(pc)print("p_d value in ParameterCollection:{}".format(pc.lookup("p_d").getDouble()))print("p_s64 value in ParameterCollection:{}".format(pc.lookup("p_s64").getS64()))print("p_vec3d value in ParameterCollection:{}".format(pc.lookup("p_vec3d").getVec3d()))sp.connected-=1# suggest to do this3.3 ResultPrint control parameter informations at consoleYou can select curves to add in phawd4 Socket example4.1 Prerequisites in phawdphawd's yaml file is as follows:RobotName:5230Type:SocketWaveParamNum:3DOUBLE:p_d:3.14159S64:p_s64:31VEC3_DOUBLE:p_vec3d:[1,2,3]Read this file using phawd, and click ready button. Then run the code demo as below.4.2 code demoA robot controller program example using Socket to communicate with phawd software:# robot controllerfromphawdimportSocketToPhawd,SocketFromPhawd,SocketConnect,Parameterif__name__=='__main__':num_ctr_params=3num_wave_params=3send_size=Parameter.__sizeof__()*num_wave_params+SocketToPhawd.__sizeof__()read_size=Parameter.__sizeof__()*num_ctr_params+SocketFromPhawd.__sizeof__()sc=SocketConnect()sc.init(send_size,read_size,False)ret=sc.connectToServer("127.0.0.1",5230,30)iter_c=0pw0=Parameter("pw0",5)pw1=Parameter("pw1",3.14)pw2=Parameter("pw2",[1,2,3])whileiter_c<500000:iter_c+=1socket_to_phawd=sc.getSend()socket_to_phawd.numWaveParams=3socket_to_phawd.parameters=[pw0,pw1,pw2]sc.send()ret=sc.read()ifret>0:socket_from_phawd=sc.getRead()ctrl_params=socket_from_phawd.parametersprint("numControlParams:{}".format(socket_from_phawd.numControlParams))print('p_d name:{}; ValueKind:{}; Value:{}'.format(ctrl_params[0].getName(),ctrl_params[0].getValueKind(),ctrl_params[0].getDouble()))print('p_s64 name:{}; ValueKind:{}; Value:{}'.format(ctrl_params[1].getName(),ctrl_params[1].getValueKind(),ctrl_params[1].getS64()))print('p_vec3d name:{}; ValueKind:{}; Value:{}'.format(ctrl_params[2].getName(),ctrl_params[2].getValueKind(),ctrl_params[2].getVec3d()))4.3 ResultOnce you modify the parameter in phawd software, this program will print parameter informations at consoleYou can select curves to add in phawd5 NotationParameters of type FLOAT and VEC3_FLOAT  are not supported in phawd_pyFor other tutorials on phawd_py, you can refer to the tests/test.pyLicensephawd_py is provided under MIT license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.