Skip to content

Commit 4af3c21

Browse files
Add files via upload
first commit
0 parents  commit 4af3c21

25 files changed

+1638
-0
lines changed

LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020, WestonRobot
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README-ZH.md

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# 松灵机器人产品BUNKER 的ROS package
2+
3+
## ROS Packages 说明
4+
5+
* bunker_bringup: launch and configuration files to start ROS nodes
6+
* bunker_base: a ROS wrapper around Bunker SDK to monitor and control the robot
7+
* bunker_msgs: bunker related message definitions
8+
* (bunker_ros: meta package for the Bunker robot ROS packages)
9+
10+
11+
下图是是整个ros package的一个基本框架说明,或许它可以帮助你理解你理解整个ros package内部是如何工作的,他们之间的是相互联系的。
12+
其中最底层的是移动机器人底盘,它通过can或者usart实现运行在计算平台的sdk进行基本信息的获取,具体可以根据wrp_sdk了解更多信息。 仿真部分是基于Webots,构建起的仿真环境。
13+
14+
<img src="./docs/diagram.png" height="135" >
15+
16+
其中上图中紫色部分是包含在这个ros-package中的部分。
17+
18+
## 通讯接口设置
19+
20+
### 设置串口
21+
22+
通常来说,usb转串口设备在Linux或者Ubuntu系统中会被自动识别为“/dev/ttyUSB0” 或者看起来类似的设备,这个可以通过指令查询
23+
```
24+
$ ls -l /dev/ttyUSB*
25+
```
26+
如果在打开设备的操作过程中出现了"... permission denied ..."的错误,有可能因为权限的原因造成的,您需要向您的用户帐户授予端口访问权限,可以通过如下指令:
27+
28+
```
29+
$ sudo usermod -a -G dialout $USER
30+
```
31+
32+
需要重新登录账户才能使刚刚的操作生效。
33+
### 配置 CAN-TO-USB适配器
34+
35+
1. 设置CAN转USB适配器,启用gs_usb内核模块(本指令需要搭配相应的硬件设备才可以使用,需要Linux内部版本>4.5)
36+
37+
```
38+
$ sudo modprobe gs_usb
39+
```
40+
41+
2. 设置can设备参数
42+
43+
```
44+
$ sudo ip link set can0 up type can bitrate 500000
45+
```
46+
47+
3. 如果在前面的步骤中没有发生错误,您可以使用以下指令查看can设备
48+
49+
```
50+
$ ifconfig -a
51+
```
52+
53+
4. 安装和使用can-utils来测试硬件
54+
55+
```
56+
$ sudo apt install can-utils
57+
```
58+
59+
5. 测试指令
60+
61+
```
62+
# receiving data from can0
63+
$ candump can0
64+
# send data to can0
65+
$ cansend can0 001#1122334455667788
66+
```
67+
68+
文件中提供了 "./scripts"文件夹里的两个脚本以便于设置。您可以在首次安装时运行“ ./setup_can2usb.bash”,并在每次拔出和重新插入适配器时运行“ ./bringup_can2usb.bash”以启动设备。
69+
70+
## ROS package 的基础使用
71+
72+
1. 安装 ROS packages 依赖
73+
74+
```
75+
$ sudo apt install ros-melodic-teleop-twist-keyboard
76+
```
77+
78+
如果你使用是 Kinetic版本,把上述指令中的“melodic” 改成 “kinetic” 即可
79+
80+
2. 将bunker ros package 下载至的您的catkin 工作空间,并编译
81+
82+
(下面的操作是假定你的catkin编译工作空间在: ~/catkin_ws/src 目录下)
83+
84+
```
85+
$ cd ~/catkin_ws/src
86+
$ git clone --recursive https://github.com/agilexrobotics/ugv_sdk.git
87+
$ git clone https://github.com/agilexrobotics/bunker_base.git
88+
$ cd ..
89+
$ catkin_make
90+
```
91+
92+
3. 配置 Webots simulation 环境
93+
94+
* 安装 Webots R2020a-rev1 (download from https://cyberbotics.com/ )
95+
96+
* 安装 Webots ROS package
97+
98+
```
99+
$ sudo apt install ros-melodic-webots-ros
100+
```
101+
102+
* 设置 WEBOTS_HOME 变量,把下面这行代码加入到 "~/.bashrc"中
103+
104+
```
105+
export WEBOTS_HOME=/usr/local/webots
106+
```
107+
108+
4. 启动 ROS nodes
109+
110+
* 开始 the base node
111+
112+
```
113+
$ roslaunch bunker_bringup bunker_minimal.launch
114+
```
115+
116+
* Start the keyboard tele-op node
117+
118+
```
119+
$ roslaunch bunker_bringup bunker_teleop_keyboard.launch
120+
```
121+
122+
**SAFETY PRECAUSION**:
123+
124+
The default command values of the keyboard teleop node are high, make sure you decrease the speed commands before starting to control the robot with your keyboard! Have your remote controller ready to take over the control whenever necessary.

README.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# ROS Packages for Bunker Mobile Robot
2+
3+
## Packages
4+
5+
This repository contains minimal packages to control the bunker robot using ROS.
6+
7+
* bunker_bringup: launch and configuration files to start ROS nodes
8+
* bunker_base: a ROS wrapper around [ugv_sdk](https://github.com/agilexrobotics/ugv_sdk) to monitor and control the bunker robot
9+
* bunker_description: URDF model for the mobile base, a sample urdf (bunker_description/sample/bunker_v2_nav.xacro) is provided for customized robot with addtional sensors
10+
* bunker_msgs: bunker related message definitions
11+
12+
### Update the packages for your customized robot
13+
14+
**Additional sensors**
15+
16+
It's likely that you may want to add additional sensors to the bunker mobile platform, such as a Lidar for navigation. In such cases, a new ".xacro" file needs to be created to describe the relative pose of the new sensor with respect to the robot base, so that the sensor frame can be reflected in the robot tf tree.
17+
18+
A [sample](bunker_description/sample/bunker_v2_nav.xacro) ".xacro" file is present in this repository, in which the base ".xacro" file of an empty bunker platform is first included, and then additional links are defined.
19+
20+
The nodes in this ROS package are made to handle only the control of the bunker base and publishing of the status. Additional nodes may need to be created by the user to handle the sensors.
21+
22+
**Alternative odometry calculation**
23+
24+
By default the bunker_base package will publish odometry message to topic "/odom". In case you want to use a different approach to calculate the odometry, for example estimating the position together with an IMU, you could rename the default odometry topic to be something else.
25+
26+
```
27+
$ bunker_bringup bunker_minimal.launch odom_topic_name:="<custom_name>"
28+
```
29+
30+
## Communication interface setup
31+
32+
Please refer to the [README](https://github.com/agilexrobotics/ugv_sdk_sdk#hardware-interface) of "ugv_sdk" package for setup of communication interfaces.
33+
34+
#### Note on CAN interface on Nvidia Jetson Platforms
35+
36+
Nvidia Jeston TX2/Xavier/XavierNX have CAN controller(s) integrated in the main SOC. If you're using a dev kit, you need to add a CAN transceiver for proper CAN communication.
37+
38+
## Basic usage of the ROS packages
39+
40+
1. Install dependent libraries
41+
42+
```
43+
$ sudo apt install -y libasio-dev
44+
$ sudo apt install -y ros-$ROS_DISTRO-teleop-twist-keyboard
45+
```
46+
47+
2. Clone the packages into your catkin workspace and compile
48+
49+
(the following instructions assume your catkin workspace is at: ~/catkin_ws/src)
50+
51+
```
52+
$ cd ~/catkin_ws/src
53+
$ git clone --recursive https://github.com/agilexrobotics/ugv_sdk.git
54+
$ git clone https://github.com/agilexrobotics/bunker_base.git
55+
$ cd ..
56+
$ catkin_make
57+
```
58+
59+
4. Launch ROS nodes
60+
61+
* Start the base node for the real robot
62+
63+
```
64+
$ roslaunch bunker_bringup bunker_minimal.launch
65+
```
66+
67+
The [bunker_bringup/bunker_minimal.launch](bunker_bringup/launch/bunker_minimal.launch) has 4 parameters:
68+
69+
- port_name: specifies the port used to communicate with the robot, default = "can0"
70+
71+
- odom_topic_name: sets the name of the topic which calculated odometry is published to, defaults = "odom"
72+
73+
74+
75+
* Start the keyboard tele-op node
76+
77+
```
78+
$ roslaunch bunker_bringup bunker_teleop_keyboard.launch
79+
```
80+
81+
**SAFETY PRECAUSION**:
82+
83+
The default command values of the keyboard teleop node are high, make sure you decrease the speed commands before starting to control the robot with your keyboard! Have your remote controller ready to take over the control whenever necessary.

bunker_base/CMakeLists.txt

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(bunker_base)
3+
4+
## Compile as C++11, supported in ROS Kinetic and newer
5+
add_compile_options(-std=c++11)
6+
7+
find_package(catkin REQUIRED COMPONENTS
8+
roslaunch
9+
roscpp
10+
sensor_msgs
11+
std_msgs
12+
geometry_msgs
13+
tf2
14+
tf2_ros
15+
ugv_sdk
16+
bunker_msgs
17+
)
18+
19+
# find_package(Boost REQUIRED COMPONENTS chrono)
20+
21+
###################################
22+
## catkin specific configuration ##
23+
###################################
24+
25+
catkin_package(
26+
INCLUDE_DIRS include
27+
LIBRARIES bunker_messenger
28+
CATKIN_DEPENDS ugv_sdk bunker_msgs
29+
# DEPENDS Boost
30+
)
31+
32+
###########
33+
## Build ##
34+
###########
35+
36+
## Specify additional locations of header files
37+
## Your package locations should be listed before other locations
38+
include_directories(
39+
include
40+
${catkin_INCLUDE_DIRS}
41+
)
42+
43+
add_library(bunker_messenger STATIC src/bunker_messenger.cpp)
44+
target_link_libraries(bunker_messenger ${catkin_LIBRARIES})
45+
add_dependencies(bunker_messenger ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
46+
47+
add_executable(bunker_base_node src/bunker_base_node.cpp)
48+
target_link_libraries(bunker_base_node bunker_messenger ${catkin_LIBRARIES})
49+
50+
#############
51+
## Install ##
52+
#############
53+
54+
install(TARGETS bunker_messenger bunker_base_node
55+
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
56+
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
57+
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
58+
59+
install(DIRECTORY include/${PROJECT_NAME}/
60+
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
61+
62+
install(DIRECTORY launch
63+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* bunker_messenger.hpp
3+
*
4+
* Created on: Jun 14, 2019 10:24
5+
* Description:
6+
*
7+
* Copyright (c) 2019 Ruixiang Du (rdu)
8+
*/
9+
10+
#ifndef BUNKER_MESSENGER_HPP
11+
#define BUNKER_MESSENGER_HPP
12+
13+
#include <string>
14+
15+
#include <ros/ros.h>
16+
#include <nav_msgs/Odometry.h>
17+
// #include <tf/transform_broadcaster.h>
18+
#include <tf2_ros/transform_broadcaster.h>
19+
20+
#include "bunker_msgs/BunkerLightCmd.h"
21+
#include "ugv_sdk/bunker/bunker_base.hpp"
22+
23+
namespace westonrobot
24+
{
25+
class BunkerROSMessenger
26+
{
27+
public:
28+
explicit BunkerROSMessenger(ros::NodeHandle *nh);
29+
BunkerROSMessenger(BunkerBase *bunker, ros::NodeHandle *nh);
30+
31+
std::string odom_frame_;
32+
std::string base_frame_;
33+
std::string odom_topic_name_;
34+
35+
bool simulated_robot_ = false;
36+
int sim_control_rate_ = 50;
37+
38+
void SetupSubscription();
39+
40+
void PublishStateToROS();
41+
void PublishSimStateToROS(double linear, double angular);
42+
43+
void GetCurrentMotionCmdForSim(double &linear, double &angular);
44+
45+
private:
46+
BunkerBase *bunker_;
47+
ros::NodeHandle *nh_;
48+
49+
std::mutex twist_mutex_;
50+
geometry_msgs::Twist current_twist_;
51+
52+
ros::Publisher odom_publisher_;
53+
ros::Publisher status_publisher_;
54+
ros::Subscriber motion_cmd_subscriber_;
55+
ros::Subscriber light_cmd_subscriber_;
56+
tf2_ros::TransformBroadcaster tf_broadcaster_;
57+
58+
// speed variables
59+
double linear_speed_ = 0.0;
60+
double angular_speed_ = 0.0;
61+
double position_x_ = 0.0;
62+
double position_y_ = 0.0;
63+
double theta_ = 0.0;
64+
65+
ros::Time last_time_;
66+
ros::Time current_time_;
67+
68+
void TwistCmdCallback(const geometry_msgs::Twist::ConstPtr &msg);
69+
void LightCmdCallback(const bunker_msgs::BunkerLightCmd::ConstPtr &msg);
70+
void PublishOdometryToROS(double linear, double angular, double dt);
71+
};
72+
} // namespace westonrobot
73+
74+
#endif /* BUNKER_MESSENGER_HPP */

0 commit comments

Comments
 (0)