diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..10f642450d1a8cd3b40796d29e52f13252a408aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin +build +lib +src/xml/*.hxx +src/xml/*.cxx diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..df839d91016ccaf029e24618df0c5967a002e1f8 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,36 @@ +image: docker.io/labrobotica/labrobotica + +stages: + - build + - test + - deploy + +build-package: + stage: build + script: +# Uncomment to install dependencies +# - apt update +# - apt -y install iri-<package_name>-dev + - apt update + - apt -y install iri-iriutils-dev iri-comm-dev + - apt install -y libxerces-c-dev xsdcxx libboost-all-dev + - mkdir -pv build + - cd build + - cmake -D CMAKE_BUILD_TYPE=RELEASE -DCPACK_PACKAGE_VERSION=$CI_COMMIT_TAG .. + - make package -j $(nproc) + artifacts: + paths: + - build/*.deb + expire_in: 2 weeks + only: + - tags + +update_repo: + stage: deploy + script: + - cd build + - "scp -i /root/.ssh/iriLabKeyNopwd -r *dynamixel*.deb irilabo@147.83.76.226:packages/" + - "ssh irilabo@147.83.76.226 -i /root/.ssh/iriLabKeyNopwd -tt /home/irilabo/repo_scripts/update_repo.sh dynamixel" + only: + - tags + diff --git a/CMakeLists.txt b/CMakeLists.txt index a925a401290d8ea74109a3f80c25869c1914446c..bad0c49321f48650c9b8f5f24c49526a90d8bc49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ endif(COMMAND cmake_policy) # The project name and the type of project PROJECT(dynamixel) +SET(PACKAGE_NAME dynamixel) SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib) @@ -71,17 +72,28 @@ ELSE(UNIX) ) ENDIF(UNIX) +IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") + SET (X86 TRUE) + SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") +ELSE () + SET (X86 FALSE) + SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386") +ENDIF() IF (UNIX) - SET(CPACK_PACKAGE_FILE_NAME "iri-${PROJECT_NAME}-dev-${CPACK_PACKAGE_VERSION}${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") - SET(CPACK_PACKAGE_NAME "iri-${PROJECT_NAME}-dev") - SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Part of IRI-laboratory libraries. More information at http://wikiri.upc.es/index.php/Robotics_Lab") - SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) + SET(CPACK_PACKAGE_FILE_NAME "iri-${PACKAGE_NAME}-dev-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") + SET(CPACK_PACKAGE_NAME "iri-${PACKAGE_NAME}-dev") + SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Part of IRI-laboratory libraries. More information at https://gitlab.iri.upc.edu/labrobotica/labrobotica_how_to") + SET(CPACK_PACKAGING_INSTALL_PREFIX /usr) SET(CPACK_GENERATOR "DEB") - SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "galenya - labrobotica@iri.upc.edu") - SET(CPACK_SET_DESTDIR "ON") # Necessary because of the absolute install paths - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "iri-iriutils-dev (>= 1.0~${DISTRIB})") - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "iri-comm-dev (>= 1.0~${DISTRIB})") + SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "labrobotica - labrobotica@iri.upc.edu") + +# Uncomment to add the necessary mantainer scripts +# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/package_scripts/preinst;${CMAKE_SOURCE_DIR}/package_scripts/postinst;${CMAKE_SOURCE_DIR}/package_scripts/prerm;${CMAKE_SOURCE_DIR}/package_scripts/postrm") + +# Uncomment to add dependencies comma separated +# SET(CPACK_DEBIAN_PACKAGE_DEPENDS "iri-<package_name>-dev (>= 1.0~${DISTRIB})") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "iri-iriutils-dev (>= 1.0~${DISTRIB}), iri-comm-dev (>= 1.0~${DISTRIB}), libxerces-c-dev (>= 1.0~${DISTRIB}), xsdcxx (>= 1.0~${DISTRIB}), libboost-all-dev (>= 1.0~${DISTRIB})") INCLUDE(CPack) ELSE(UNIX) diff --git a/Finddynamixel.cmake b/Finddynamixel.cmake index 0a8f5c850eaf2885083b13271c9249c4c8c5be90..97406cb912b658b40ad00fce0a3aca073f0f0f1f 100644 --- a/Finddynamixel.cmake +++ b/Finddynamixel.cmake @@ -1,17 +1,20 @@ #edit the following line to add the librarie's header files -FIND_PATH(dynamixel_INCLUDE_DIR dynamixel.h dynamixelserver.h dynamixelexceptions.h /usr/include/iridrivers /usr/local/include/iridrivers) +FIND_PATH(dynamixel_INCLUDE_DIRS dynamixel.h dynamixelserver.h dynamixelexceptions.h dynamixel_common.h dynamixel_slave.h dynamixel_slave_ftdi.h dynamixel_slave_serial.h dynamixelserver_ftdi.h dynamixelserver_serial.h /usr/local/include/iri/dynamixel /usr/include/iri/dynamixel) -FIND_LIBRARY(dynamixel_LIBRARY +FIND_LIBRARY(dynamixel_LIBRARIES NAMES dynamixel - PATHS /usr/lib/iridrivers /usr/local/lib /usr/local/lib/iridrivers) + PATHS /usr/local/lib/iri/dynamixel /usr/lib/iri/dynamixel) -IF (dynamixel_INCLUDE_DIR AND dynamixel_LIBRARY) +SET(dynamixel_INCLUDE_DIR ${dynamixel_INCLUDE_DIRS}) +SET(dynamixel_LIBRARY ${dynamixel_LIBRARIES}) + +IF (dynamixel_INCLUDE_DIRS AND dynamixel_LIBRARIES) SET(dynamixel_FOUND TRUE) -ENDIF (dynamixel_INCLUDE_DIR AND dynamixel_LIBRARY) +ENDIF (dynamixel_INCLUDE_DIRS AND dynamixel_LIBRARIES) IF (dynamixel_FOUND) IF (NOT dynamixel_FIND_QUIETLY) - MESSAGE(STATUS "Found dynamixel: ${dynamixel_LIBRARY}") + MESSAGE(STATUS "Found dynamixel: ${dynamixel_LIBRARIES}") ENDIF (NOT dynamixel_FIND_QUIETLY) ELSE (dynamixel_FOUND) IF (dynamixel_FIND_REQUIRED) diff --git a/ReadMe.md b/ReadMe.md index 0ef8625d42d67510e7012b61f27cc28bcb87a4f8..d7d1430109f0176199e2aff81697b948c2edc5df 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -3,7 +3,7 @@ Dynamixel {#mainpage} ## Description -This library provide a server to handle all the devices connected to a Dynamixel Bus and also low level read and write functions to access each one of this devices. +This library provides a server to handle all the devices connected to a Dynamixel Bus and also low level read and write functions to access each one. The server allows to: @@ -21,6 +21,46 @@ For each device, the following operations are provided: - Broadcast a command to several devices. +## Installation + +* Add the labrobotica repository if it is not already added: + +``` sudo sh -c 'echo "deb [arch=amd64] http://147.83.76.226/~irilabo/packages xenial main" > /etc/apt/sources.list.d/labrobotica_repo.list' ``` + +``` wget -O - http://147.83.76.226/~irilabo/labrobotica_repo.gpg.key | sudo apt-key add - ``` + +* Install the package: + +``` sudo apt update && sudo apt install iri-dynamixel-dev ``` + +## Important information + +To use this driver is necessary to unload the *ftdi_sio* module, so the device is detected as a serial-usb device. +This can be achieved with the following command + + ```sudo rmmod ftdi_sio``` + +or executing the following script: + + ```unbind_ftdi_udev.sh -s <serial_number>``` + +## Disclaimer + +Copyright (C) 2009-2019 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +Mantainer IRI labrobotics (labrobotica@iri.upc.edu) + +This package is distributed in the hope that it will be useful, but without any warranty. It is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. should the program prove defective, the GMR group does not assume the cost of any necessary servicing, repair or correction. + +In no event unless required by applicable law the author will be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the program to operate with any other programs), even if the author has been advised of the possibility of such damages. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see <http://www.gnu.org/licenses/> + +## For developers + +<details><summary>click here</summary> +<p> + ## Dependencies This package requires of the following system libraries and packages @@ -41,9 +81,9 @@ This package also requires of the following IRI libraries: * [comm](https://gitlab.iri.upc.edu/labrobotica/drivers/comm "comm gitlab page"), a set of basic communication drivers. -## Compilation and installation +## Compilation and installation from source -Download this repository and create a build folder inside: +Clone this repository and create a build folder inside: ``` mkdir build ``` @@ -68,9 +108,10 @@ To do that, execute ``` make install ``` -as root and the shared libraries will be copied to */usr/local/lib/iridrivers* directory -and the header files will be copied to */usr/local/include/iridrivers* directory. At -this point, the library may be used by any user. +as root and the shared libraries will be copied to */usr/local/lib/iri/dynamixel* directory +and the header files will be copied to */usr/local/include/iri/dynamixel* dierctory. If the +support for XML file is enabled, all the necessary files will be copied to */usr/local/include/iri/dynamixel/xml*. + At this point, the library may be used by any user. To remove the library from the system, exceute @@ -86,25 +127,21 @@ To generate the documentation execute the following command: To use this library in an other library or application, in the CMakeLists.txt file, first it is necessary to locate if the library has been installed or not using the following command -``` FIND_PACKAGE(project_name) ``` +``` FIND_PACKAGE(dynamixel) ``` In the case that the package is present, it is necessary to add the header files directory to the include directory path by using -``` INCLUDE_DIRECTORIES(${project_name_INCLUDE_DIR}) ``` +``` INCLUDE_DIRECTORIES(${dynamixel_INCLUDE_DIR}) ``` and it is also necessary to link with the desired libraries by using the following command -``` TARGET_LINK_LIBRARIES(<executable name> ${project_name_LIBRARY}) ``` +``` TARGET_LINK_LIBRARIES(<executable name> ${dynamixel_LIBRARY}) ``` -## Disclaimer - -Copyright (C) 2009-2018 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. -Mantainer author_name (author_email) +## Examples -This package is distributed in the hope that it will be useful, but without any warranty. It is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. should the program prove defective, the GMR group does not assume the cost of any necessary servicing, repair or correction. +There are several examples that show how to use the different classes. -In no event unless required by applicable law the author will be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the program to operate with any other programs), even if the author has been advised of the possibility of such damages. +</p> +</details> -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see <http://www.gnu.org/licenses/> diff --git a/src/dynamixel.h b/include/dynamixel.h similarity index 100% rename from src/dynamixel.h rename to include/dynamixel.h diff --git a/src/dynamixel_common.h b/include/dynamixel_common.h similarity index 100% rename from src/dynamixel_common.h rename to include/dynamixel_common.h diff --git a/src/dynamixel_slave.h b/include/dynamixel_slave.h similarity index 100% rename from src/dynamixel_slave.h rename to include/dynamixel_slave.h diff --git a/src/dynamixel_slave_ftdi.h b/include/dynamixel_slave_ftdi.h similarity index 100% rename from src/dynamixel_slave_ftdi.h rename to include/dynamixel_slave_ftdi.h diff --git a/src/dynamixel_slave_serial.h b/include/dynamixel_slave_serial.h similarity index 100% rename from src/dynamixel_slave_serial.h rename to include/dynamixel_slave_serial.h diff --git a/src/dynamixelexceptions.h b/include/dynamixelexceptions.h similarity index 100% rename from src/dynamixelexceptions.h rename to include/dynamixelexceptions.h diff --git a/src/dynamixelserver.h b/include/dynamixelserver.h similarity index 100% rename from src/dynamixelserver.h rename to include/dynamixelserver.h diff --git a/src/dynamixelserver_ftdi.h b/include/dynamixelserver_ftdi.h similarity index 100% rename from src/dynamixelserver_ftdi.h rename to include/dynamixelserver_ftdi.h diff --git a/src/dynamixelserver_serial.h b/include/dynamixelserver_serial.h similarity index 100% rename from src/dynamixelserver_serial.h rename to include/dynamixelserver_serial.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 95f8ba91984e0b15d0aab74a43850b534d9bc116..f325bc8eac42cee920082fa172e8a914a8831e58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,9 +3,9 @@ ADD_SUBDIRECTORY(xml) # edit the following line to add all the source code files of the library SET(sources dynamixel.cpp dynamixelserver.cpp dynamixelserver_ftdi.cpp dynamixelserver_serial.cpp dynamixelexceptions.cpp dynamixel_slave.cpp dynamixel_slave_ftdi.cpp dynamixel_slave_serial.cpp) # edit the following line to add all the header files of the library -SET(headers dynamixel.h dynamixelserver.h dynamixelserver_ftdi.h dynamixelserver_serial.h dynamixelexceptions.h dynamixel_common.h dynamixel_slave.h dynamixel_slave_ftdi.h dynamixel_slave_serial.h) +SET(headers ../include/dynamixel.h ../include/dynamixelserver.h ../include/dynamixelserver_ftdi.h ../include/dynamixelserver_serial.h ../include/dynamixelexceptions.h ../include/dynamixel_common.h ../include/dynamixel_slave.h ../include/dynamixel_slave_ftdi.h ../include/dynamixel_slave_serial.h) -INCLUDE_DIRECTORIES(.) +INCLUDE_DIRECTORIES(. ../include) # edit the following line to find the necessary packages FIND_PACKAGE(iriutils REQUIRED) @@ -13,8 +13,8 @@ FIND_PACKAGE(comm REQUIRED) find_package(Boost REQUIRED) # edit the following line to add the necessary include directories -INCLUDE_DIRECTORIES(${iriutils_INCLUDE_DIR}) -INCLUDE_DIRECTORIES(${comm_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${iriutils_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${comm_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) SET_SOURCE_FILES_PROPERTIES(${XSD_SOURCES} PROPERTIES GENERATED 1) @@ -22,20 +22,20 @@ SET_SOURCE_FILES_PROPERTIES(${XSD_SOURCES} PROPERTIES GENERATED 1) ADD_LIBRARY(dynamixel SHARED ${sources} ${XSD_SOURCES}) #edit the following line to add the necessary system libraries (if any) -TARGET_LINK_LIBRARIES(dynamixel ${iriutils_LIBRARY}) -TARGET_LINK_LIBRARIES(dynamixel ${comm_LIBRARY}) -TARGET_LINK_LIBRARIES(dynamixel ${XSD_LIBRARY}) +TARGET_LINK_LIBRARIES(dynamixel ${iriutils_LIBRARIES}) +TARGET_LINK_LIBRARIES(dynamixel ${comm_LIBRARIES}) +TARGET_LINK_LIBRARIES(dynamixel ${XSD_LIBRARIES}) TARGET_LINK_LIBRARIES(dynamixel ${Boost_LIBRARIES}) ADD_DEPENDENCIES(dynamixel xsd_files_gen) INSTALL(TARGETS dynamixel RUNTIME DESTINATION bin - LIBRARY DESTINATION lib/iridrivers - ARCHIVE DESTINATION lib/iridrivers + LIBRARY DESTINATION lib/iri/${PROJECT_NAME} + ARCHIVE DESTINATION lib/iri/${PROJECT_NAME} ) -INSTALL(FILES ${headers} DESTINATION include/iridrivers) +INSTALL(FILES ${headers} DESTINATION include/iri/${PROJECT_NAME}) INSTALL(FILES ../Finddynamixel.cmake DESTINATION ${CMAKE_ROOT}/Modules/) diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index 44ddee0ec293cadfbd7ff6fee11ed7b3c06aea85..1a4a350e0aa0687fcbe60dff22a89823fd3d620f 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -4,14 +4,16 @@ IF(EXISTS "/usr/include/xsd/cxx") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_HAVE_XSD" PARENT_SCOPE) SET(XSD_FOUND TRUE) MESSAGE(STATUS "Found the XML library ... adding support for XML files") - FIND_LIBRARY(XSD_LIBRARY + FIND_LIBRARY(XSD_LIBRARIES NAMES xerces-c - PATHS /usr/lib /usr/local/lib) + PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu/) + SET(XSD_LIBRARY ${XSD_LIBRARIES}) ELSE(EXISTS "/usr/include/xsd/cxx") MESSAGE(STATUS "XML library not found ... it will be impossible to handle XML files") ENDIF(EXISTS "/usr/include/xsd/cxx") IF(XSD_FOUND) + SET(XSD_LIBRARIES ${XSD_LIBRARIES} PARENT_SCOPE) SET(XSD_LIBRARY ${XSD_LIBRARY} PARENT_SCOPE) SET(XSD_PATH ${CMAKE_CURRENT_SOURCE_DIR}) @@ -39,7 +41,7 @@ IF(XSD_FOUND) DEPENDS ${XSD_PATH_FILES} COMMENT "Parsing the xml template file ${XSD_FILES}") - INSTALL(FILES ${XSD_PATH_FILES} DESTINATION include/iridrivers/xml) - INSTALL(FILES ${XSD_HEADERS_INT} DESTINATION include/iridrivers/xml) + INSTALL(FILES ${XSD_PATH_FILES} DESTINATION include/iri/${PROJECT_NAME}/xml) + INSTALL(FILES ${XSD_HEADERS_INT} DESTINATION include/iri/${PROJECT_NAME}/xml) ENDIF(XSD_FILES) ENDIF(XSD_FOUND)