-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
Apr 23, 2023
0 parents
commit 29cd883
Showing
61 changed files
with
9,441 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# 松灵机器人产品SCOUT 的ROS package | ||
|
||
## ROS Packages 说明 | ||
|
||
* scout_bringup: launch and configuration files to start ROS nodes | ||
* scout_base: a ROS wrapper around Scout SDK to monitor and control the robot | ||
* scout_msgs: scout related message definitions | ||
* (scout_ros: meta package for the Scout robot ROS packages) | ||
|
||
|
||
下图是是整个ros package的一个基本框架说明,或许它可以帮助你理解你理解整个ros package内部是如何工作的,他们之间的是相互联系的。 | ||
其中最底层的是移动机器人底盘,它通过can或者usart实现运行在计算平台的sdk进行基本信息的获取,具体可以根据wrp_sdk了解更多信息。 仿真部分是基于Webots,构建起的仿真环境。 | ||
|
||
<img src="./docs/diagram.png" height="135" > | ||
|
||
其中上图中紫色部分是包含在这个ros-package中的部分。 | ||
|
||
## 通讯接口设置 | ||
|
||
### 设置串口 | ||
|
||
通常来说,usb转串口设备在Linux或者Ubuntu系统中会被自动识别为“/dev/ttyUSB0” 或者看起来类似的设备,这个可以通过指令查询 | ||
``` | ||
$ ls -l /dev/ttyUSB* | ||
``` | ||
如果在打开设备的操作过程中出现了"... permission denied ..."的错误,有可能因为权限的原因造成的,您需要向您的用户帐户授予端口访问权限,可以通过如下指令: | ||
|
||
``` | ||
$ sudo usermod -a -G dialout $USER | ||
``` | ||
|
||
需要重新登录账户才能使刚刚的操作生效。 | ||
### 配置 CAN-TO-USB适配器 | ||
|
||
1. 设置CAN转USB适配器,启用gs_usb内核模块(本指令需要搭配相应的硬件设备才可以使用,需要Linux内部版本>4.5) | ||
|
||
``` | ||
$ sudo modprobe gs_usb | ||
``` | ||
|
||
2. 设置can设备参数 | ||
|
||
``` | ||
$ sudo ip link set can0 up type can bitrate 500000 | ||
``` | ||
|
||
3. 如果在前面的步骤中没有发生错误,您可以使用以下指令查看can设备 | ||
|
||
``` | ||
$ ifconfig -a | ||
``` | ||
|
||
4. 安装和使用can-utils来测试硬件 | ||
|
||
``` | ||
$ sudo apt install can-utils | ||
``` | ||
|
||
5. 测试指令 | ||
|
||
``` | ||
# receiving data from can0 | ||
$ candump can0 | ||
# send data to can0 | ||
$ cansend can0 001#1122334455667788 | ||
``` | ||
|
||
文件中提供了 "./scripts"文件夹里的两个脚本以便于设置。您可以在首次安装时运行“ ./setup_can2usb.bash”,并在每次拔出和重新插入适配器时运行“ ./bringup_can2usb.bash”以启动设备。 | ||
|
||
## ROS package 的基础使用 | ||
|
||
1. 安装 ROS packages 依赖 | ||
|
||
``` | ||
$ sudo apt install ros-melodic-teleop-twist-keyboard | ||
``` | ||
|
||
如果你使用是 Kinetic版本,把上述指令中的“melodic” 改成 “kinetic” 即可 | ||
|
||
2. 将scout ros package 下载至的您的catkin 工作空间,并编译 | ||
|
||
(下面的操作是假定你的catkin编译工作空间在: ~/catkin_ws/src 目录下) | ||
|
||
``` | ||
$ cd ~/catkin_ws/src | ||
$ git clone --recursive https://github.com/agilexrobotics/ugv_sdk.git | ||
$ git clone https://github.com/agilexrobotics/scout_ros.git | ||
$ cd .. | ||
$ catkin_make | ||
``` | ||
如果你买的小车版本是1.0通信协议版本,执行以下指令切换ugv_sdk的版本至1.0版本 | ||
``` | ||
$ cd ugv_sdk && git checkout master | ||
``` | ||
然后重新编译 | ||
|
||
3. 启动 ROS nodes | ||
|
||
* 启动scout车节点 | ||
|
||
``` | ||
$ roslaunch scout_bringup scout_minimal.launch | ||
``` | ||
|
||
* 启动scout-mini车节点 | ||
|
||
``` | ||
$ roslaunch scout_bringup scout_mini_minimal.launch | ||
``` | ||
|
||
* 启动scout-mini车的全向轮模式(麦克纳母轮) | ||
|
||
```bash | ||
$ roslaunch scout_bringup scout_miniomni_robot_base.launch | ||
``` | ||
|
||
* Start the keyboard tele-op node | ||
|
||
``` | ||
$ roslaunch scout_bringup scout_teleop_keyboard.launch | ||
``` | ||
|
||
**SAFETY PRECAUSION**: | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# ROS Packages for Scout Mobile Robot | ||
|
||
## Packages | ||
|
||
This repository contains minimal packages to control the scout robot using ROS. | ||
|
||
* scout_bringup: launch and configuration files to start ROS nodes | ||
* scout_base: a ROS wrapper around [ugv_sdk](https://github.com/agilexrobotics/ugv_sdk) to monitor and control the scout robot | ||
* scout_description: URDF model for the mobile base, a sample urdf (scout_description/sample/scout_v2_nav.xacro) is provided for customized robot with addtional sensors | ||
* scout_msgs: scout related message definitions | ||
|
||
### Update the packages for your customized robot | ||
|
||
**Additional sensors** | ||
|
||
It's likely that you may want to add additional sensors to the scout 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. | ||
|
||
A [sample](scout_description/sample/scout_v2_nav.xacro) ".xacro" file is present in this repository, in which the base ".xacro" file of an empty scout platform is first included, and then additional links are defined. | ||
|
||
The nodes in this ROS package are made to handle only the control of the scout base and publishing of the status. Additional nodes may need to be created by the user to handle the sensors. | ||
|
||
**Alternative odometry calculation** | ||
|
||
By default the scout_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. | ||
|
||
``` | ||
$ roslaunch scout_bringup scout_base_robot.launch odom_topic_name:="<custom_name>" | ||
``` | ||
|
||
## Communication interface setup | ||
|
||
Please refer to the [README](https://github.com/westonrobot/ugv_sdk_sdk#hardware-interface) of "ugv_sdk" package for setup of communication interfaces. | ||
|
||
#### Note on CAN interface on Nvidia Jetson Platforms | ||
|
||
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. | ||
|
||
## Basic usage of the ROS packages | ||
|
||
1. Install dependent libraries | ||
|
||
``` | ||
$ sudo apt install -y libasio-dev | ||
$ sudo apt install -y ros-$ROS_DISTRO-teleop-twist-keyboard | ||
``` | ||
|
||
2. Clone the packages into your catkin workspace and compile | ||
|
||
(the following instructions assume your catkin workspace is at: ~/catkin_ws/src) | ||
|
||
``` | ||
$ cd ~/catkin_ws/src | ||
$ git clone https://github.com/agilexrobotics/ugv_sdk.git | ||
$ git clone https://github.com/agilexrobotics/scout_ros.git | ||
$ cd .. | ||
$ catkin_make | ||
``` | ||
|
||
3. Setup CAN-To-USB adapter | ||
|
||
* Enable gs_usb kernel module(If you have already added this module, you do not need to add it) | ||
``` | ||
$ sudo modprobe gs_usb | ||
``` | ||
|
||
* first time use scout-ros package | ||
``` | ||
$ rosrun scout_bringup setup_can2usb.bash | ||
``` | ||
|
||
* if not the first time use scout-ros package(Run this command every time you turn off the power) | ||
``` | ||
$ rosrun scout_bringup bringup_can2usb.bash | ||
``` | ||
|
||
* Testing command | ||
``` | ||
# receiving data from can0 | ||
$ candump can0 | ||
``` | ||
|
||
4. Launch ROS nodes | ||
|
||
* Start the base node for scout | ||
|
||
``` | ||
$ roslaunch scout_bringup scout_robot_base.launch | ||
``` | ||
|
||
The [scout_bringup/scout_minimal.launch](scout_bringup/launch/scout_minimal.launch) has 5 parameters: | ||
|
||
- port_name: specifies the port used to communicate with the robot, default = "can0" | ||
- simulated_robot: indicates if launching with a simulation, default = "false" | ||
- model_xacro: specifies the target ".xacro" file for the publishing of tf frames, default = [scout_v2.xacro](scout_base/description/scout_v2.xacro) | ||
- odom_topic_name: sets the name of the topic which calculated odometry is published to, defaults = "odom" | ||
- is_scout_mini:Suitable for chassis of type scout_mini,defaults = "false" | ||
|
||
* Start the base node for scout-mini | ||
|
||
``` | ||
$ roslaunch scout_bringup scout_mini_robot_base.launch | ||
``` | ||
|
||
* Start the base node for scout-min(omni mode) | ||
|
||
```bash | ||
$ roslaunch scout_bringup scout_miniomni_robot_base.launch | ||
``` | ||
|
||
|
||
* Start the keyboard tele-op node | ||
|
||
``` | ||
$ roslaunch scout_bringup scout_teleop_keyboard.launch | ||
``` | ||
|
||
**SAFETY PRECAUSION**: | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(scout_base) | ||
|
||
## Compile as C++11, supported in ROS Kinetic and newer | ||
add_compile_options(-std=c++11) | ||
|
||
find_package(catkin REQUIRED COMPONENTS | ||
roslaunch | ||
roscpp | ||
sensor_msgs | ||
std_msgs | ||
geometry_msgs | ||
tf2 | ||
tf2_ros | ||
ugv_sdk | ||
scout_msgs | ||
) | ||
|
||
# find_package(Boost REQUIRED COMPONENTS chrono) | ||
|
||
################################### | ||
## catkin specific configuration ## | ||
################################### | ||
|
||
catkin_package( | ||
INCLUDE_DIRS include | ||
LIBRARIES scout_messenger | ||
CATKIN_DEPENDS ugv_sdk scout_msgs | ||
# DEPENDS Boost | ||
) | ||
|
||
########### | ||
## Build ## | ||
########### | ||
|
||
## Specify additional locations of header files | ||
## Your package locations should be listed before other locations | ||
include_directories( | ||
include | ||
${catkin_INCLUDE_DIRS} | ||
) | ||
|
||
add_library(scout_messenger STATIC src/scout_messenger.cpp) | ||
target_link_libraries(scout_messenger ${catkin_LIBRARIES}) | ||
add_dependencies(scout_messenger ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) | ||
|
||
add_executable(scout_base_node src/scout_base_node.cpp) | ||
target_link_libraries(scout_base_node scout_messenger ${catkin_LIBRARIES}) | ||
|
||
############# | ||
## Install ## | ||
############# | ||
|
||
install(TARGETS scout_messenger scout_base_node | ||
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} | ||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) | ||
|
||
install(DIRECTORY include/${PROJECT_NAME}/ | ||
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}) | ||
|
||
install(DIRECTORY launch | ||
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* scout_messenger.hpp | ||
* | ||
* Created on: Jun 14, 2019 10:24 | ||
* Description: | ||
* | ||
* Copyright (c) 2019 Ruixiang Du (rdu) | ||
*/ | ||
|
||
#ifndef SCOUT_MESSENGER_HPP | ||
#define SCOUT_MESSENGER_HPP | ||
|
||
#include <string> | ||
|
||
#include <ros/ros.h> | ||
#include <nav_msgs/Odometry.h> | ||
// #include <tf/transform_broadcaster.h> | ||
#include <tf2_ros/transform_broadcaster.h> | ||
|
||
#include "scout_msgs/ScoutLightCmd.h" | ||
#include "ugv_sdk/mobile_robot/scout_robot.hpp" | ||
#include <mutex> | ||
|
||
namespace westonrobot | ||
{ | ||
class ScoutROSMessenger | ||
{ | ||
public: | ||
explicit ScoutROSMessenger(ros::NodeHandle *nh); | ||
ScoutROSMessenger(ScoutRobot *scout, ros::NodeHandle *nh, bool is_scout_omni); | ||
|
||
std::string odom_frame_; | ||
std::string base_frame_; | ||
std::string odom_topic_name_; | ||
bool pub_tf; | ||
bool is_scout_omni; | ||
bool simulated_robot_ = false; | ||
int sim_control_rate_ = 50; | ||
|
||
void SetupSubscription(); | ||
|
||
void PublishStateToROS(); | ||
void PublishSimStateToROS(double linear, double angular); | ||
|
||
void GetCurrentMotionCmdForSim(double &linear, double &angular); | ||
|
||
private: | ||
ScoutRobot *scout_; | ||
ros::NodeHandle *nh_; | ||
|
||
std::mutex twist_mutex_; | ||
geometry_msgs::Twist current_twist_; | ||
|
||
ros::Publisher odom_publisher_; | ||
ros::Publisher status_publisher_; | ||
ros::Publisher BMS_status_publisher_; | ||
ros::Subscriber motion_cmd_subscriber_; | ||
ros::Subscriber light_cmd_subscriber_; | ||
tf2_ros::TransformBroadcaster tf_broadcaster_; | ||
|
||
// speed variables | ||
double linear_speed_ = 0.0; | ||
double angular_speed_ = 0.0; | ||
double position_x_ = 0.0; | ||
double position_y_ = 0.0; | ||
double theta_ = 0.0; | ||
|
||
ros::Time last_time_; | ||
ros::Time current_time_; | ||
|
||
void TwistCmdCallback(const geometry_msgs::Twist::ConstPtr &msg); | ||
void LightCmdCallback(const scout_msgs::ScoutLightCmd::ConstPtr &msg); | ||
void PublishOdometryToROS(double linear, double angular, double dt); | ||
}; | ||
} // namespace westonrobot | ||
|
||
#endif /* SCOUT_MESSENGER_HPP */ |
Oops, something went wrong.