Skip to content

Commit

Permalink
add package xarm_msgs, xarm_sdk, xarm_api
Browse files Browse the repository at this point in the history
  • Loading branch information
vimior committed Apr 14, 2021
1 parent e2b5da8 commit 805663e
Show file tree
Hide file tree
Showing 50 changed files with 2,723 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "xarm_sdk/cxx"]
path = xarm_sdk/cxx
url = https://github.com/xArm-Developer/xArm-CPLUS-SDK.git
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2018, UFACTORY Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 3 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# xarm_ros2

[xarm_ros2 test doc](./ReadMe_cn.md)
55 changes: 55 additions & 0 deletions ReadMe_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# xarm_ros2测试说明(暂定调试使用)

## 获取源码包
```bash
$ cd ~/dev_ws/src
$ git clone [email protected]:vinman/xarm_ros2.git --recursive
```

## 升级源码包
```bash
$ cd ~/dev_ws/src/xarm_ros2
$ git pull
$ git submodule sync
$ git submodule update --remote
```

## 编译
```bash
$ cd ~/dev_ws/
# 编译所有包
$ colcon build
# 编译单个包
# $ colcon build --packages-select xarm_api
```

## 测试
### 测试包(xarm_api)
- #### 运行 xarm_driver_node
```bash
$ cd ~/dev_ws/
$ source install/setup.bash
# 通过xarm6_driver.launch启动
$ ros2 launch xarm_api xarm6_driver.launch robot_ip:=192.168.1.117
# 通过xarm_driver_launch.py启动
# $ ros2 launch xarm_api xarm_driver_launch.py robot_ip:=192.168.1.117 dof:=6
```
- #### 测试 xarm_ros_client
```bash
$ cd ~/dev_ws/
$ source install/setup.bash
$ ros2 run xarm_api test_xarm_ros_client
```
- #### 测试 xarm_velo_move
```bash
$ cd ~/dev_ws/
$ source install/setup.bash
$ ros2 run xarm_api test_xarm_velo_move
```

- #### 测试 xarm_states_topic
```bash
$ cd ~/dev_ws/
$ source install/setup.bash
$ ros2 run xarm_api test_xarm_states
```
117 changes: 117 additions & 0 deletions xarm_api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
cmake_minimum_required(VERSION 3.5)
project(xarm_api)

# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic
-Wno-sign-compare
-Wno-unused-parameter
-Wno-unused-variable
)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(xarm_msgs REQUIRED)
find_package(xarm_sdk REQUIRED)

include_directories(
include
${xarm_sdk_INCLUDE_DIRS}
${ament_INCLUDE_DIRS}
)

set(dependencies "rclcpp" "std_msgs" "sensor_msgs" "xarm_msgs")

add_executable(xarm_driver_node
src/xarm_driver_node.cpp
src/xarm_driver.cpp
)

ament_target_dependencies(xarm_driver_node ${dependencies})
target_link_libraries(xarm_driver_node
${xarm_sdk_LIBRARIES}
${ament_LIBRARIES}
)

add_library(xarm_ros_client SHARED
src/xarm_ros_client.cpp
)
ament_target_dependencies(xarm_ros_client ${dependencies})


add_executable(test_xarm_ros_client
test/test_xarm_ros_client.cpp
)
ament_target_dependencies(test_xarm_ros_client ${dependencies})
target_link_libraries(test_xarm_ros_client
xarm_ros_client
${ament_LIBRARIES}
)

add_executable(test_xarm_velo_move
test/test_xarm_velo_move.cpp
)
ament_target_dependencies(test_xarm_velo_move ${dependencies})
target_link_libraries(test_xarm_velo_move
xarm_ros_client
${ament_LIBRARIES}
)

add_executable(test_xarm_states
test/test_xarm_states.cpp
)
ament_target_dependencies(test_xarm_states ${dependencies})

ament_export_libraries(xarm_ros_client)
ament_export_include_directories(include)

install(
TARGETS xarm_ros_client
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

install(
TARGETS
xarm_driver_node
test_xarm_ros_client
test_xarm_velo_move
test_xarm_states
DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY
launch
config
DESTINATION share/${PROJECT_NAME}/
)

ament_package()
5 changes: 5 additions & 0 deletions xarm_api/config/xarm_params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
xarm:
xarm_driver:
ros__parameters:
DOF: 7
joint_names: ['joint1', 'joint2', 'joint3', 'joint4', 'joint5', 'joint6', 'joint7']
98 changes: 98 additions & 0 deletions xarm_api/include/visibility_control.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright (c) 2019, Open Source Robotics Foundation, Inc.
// All rights reserved.
//
// Software License Agreement (BSD License 2.0)
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Open Source Robotics Foundation, Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef XARM_API__VISIBILITY_CONTROL_HPP_
#define XARM_API__VISIBILITY_CONTROL_HPP_

// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
// https://gcc.gnu.org/wiki/Visibility

#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define XARM_API_EXPORT __attribute__ ((dllexport))
#define XARM_API_IMPORT __attribute__ ((dllimport))
#else
#define XARM_API_EXPORT __declspec(dllexport)
#define XARM_API_IMPORT __declspec(dllimport)
#endif
#ifdef XARM_API_BUILDING_LIBRARY
#define XARM_API_PUBLIC XARM_API_EXPORT
#else
#define XARM_API_PUBLIC XARM_API_IMPORT
#endif
#define XARM_API_PUBLIC_TYPE XARM_API_PUBLIC
#define XARM_API_LOCAL
#else
#define XARM_API_EXPORT __attribute__ ((visibility("default")))
#define XARM_API_IMPORT
#if __GNUC__ >= 4
#define XARM_API_PUBLIC __attribute__ ((visibility("default")))
#define XARM_API_LOCAL __attribute__ ((visibility("hidden")))
#else
#define XARM_API_PUBLIC
#define XARM_API_LOCAL
#endif
#define XARM_API_PUBLIC_TYPE
#endif

#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define XARM_API_PLUGIN_EXPORT __attribute__ ((dllexport))
#define XARM_API_PLUGIN_IMPORT __attribute__ ((dllimport))
#else
#define XARM_API_PLUGIN_EXPORT __declspec(dllexport)
#define XARM_API_PLUGIN_IMPORT __declspec(dllimport)
#endif
#ifdef XARM_API_PLUGIN_BUILDING_LIBRARY
#define XARM_API_PLUGIN_PUBLIC XARM_API_PLUGIN_EXPORT
#else
#define XARM_API_PLUGIN_PUBLIC XARM_API_PLUGIN_IMPORT
#endif
#define XARM_API_PLUGIN_PUBLIC_TYPE XARM_API_PLUGIN_PUBLIC
#define XARM_API_PLUGIN_LOCAL
#else
#define XARM_API_PLUGIN_EXPORT __attribute__ ((visibility("default")))
#define XARM_API_PLUGIN_IMPORT
#if __GNUC__ >= 4
#define XARM_API_PLUGIN_PUBLIC __attribute__ ((visibility("default")))
#define XARM_API_PLUGIN_LOCAL __attribute__ ((visibility("hidden")))
#else
#define XARM_API_PLUGIN_PUBLIC
#define XARM_API_PLUGIN_LOCAL
#endif
#define XARM_API_PLUGIN_PUBLIC_TYPE
#endif

#endif // XARM_API__VISIBILITY_CONTROL_HPP_
Loading

0 comments on commit 805663e

Please sign in to comment.