From ef72005125eaa66c2958fc459d8af239a8d615b4 Mon Sep 17 00:00:00 2001 From: Ruixiang Du Date: Thu, 10 Oct 2019 11:13:11 +0800 Subject: [PATCH] updated launch files and readme --- NOTE.md | 19 ----- README.md | 77 +++++++++++++++++-- scout_base/launch/robot_model.launch | 17 ---- scout_base/launch/scout_base.launch | 18 ++++- scout_base/launch/view_scout_model.launch | 6 ++ scout_base/src/scout_base_node.cpp | 20 +++-- scout_bringup/CMakeLists.txt | 2 +- scout_bringup/launch/scout_minimal.launch | 5 +- .../launch/scout_minimal_uart.launch | 6 ++ scout_bringup/scripts/bringup_can2usb.bash | 4 + scout_bringup/scripts/setup_can2usb.bash | 10 +++ 11 files changed, 130 insertions(+), 54 deletions(-) delete mode 100644 NOTE.md delete mode 100644 scout_base/launch/robot_model.launch create mode 100644 scout_base/launch/view_scout_model.launch create mode 100644 scout_bringup/launch/scout_minimal_uart.launch create mode 100755 scout_bringup/scripts/bringup_can2usb.bash create mode 100755 scout_bringup/scripts/setup_can2usb.bash diff --git a/NOTE.md b/NOTE.md deleted file mode 100644 index 222758d..0000000 --- a/NOTE.md +++ /dev/null @@ -1,19 +0,0 @@ -``` -$ sudo apt-get install ros-kinetic-joint-state-controller -$ sudo apt-get install ros-kinetic-effort-controllers -$ sudo apt-get install ros-kinetic-position-controllers -``` - -``` -$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=scout_robot/cmd_vel -``` - -xacro to URDF -``` -$ rosrun xacro xacro scout.urdf.xacro > agilex_scout.urdf -``` - -URDF to PROTO -``` -$ python urdf2webots.py --input=someRobot.urdf [--output=outputFile] [--box-collision] [--normal] -``` diff --git a/README.md b/README.md index 9521619..faae325 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,60 @@ * 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_sdk: Scout SDK customized for ROS * scout_msgs: scout related message definitions -* (scout_robot: meta package for the Scout robot ROS packages) +* (scout_ros: meta package for the Scout robot ROS packages) -## Basic Usage +## Communication interface setup + +### Setup CAN-To-USB adapter + +1. Enable gs_usb kernel module + + ``` + $ sudo modprobe gs_usb + ``` + +2. Bringup can device + + ``` + $ sudo ip link set can0 up type can bitrate 500000 + ``` + +3. If no error occured during the previous steps, you should be able to see the can device now by using command + + ``` + $ ifconfig -a + ``` + +4. Install and use can-utils to test the hardware + + ``` + $ sudo apt install can-utils + ``` + +5. Testing command + + ``` + # receiving data from can0 + $ candump can0 + # send data to can0 + $ cansend can0 001#1122334455667788 + ``` + +Two scripts inside the "scout_bringup/scripts" folder are provided for easy setup. You can run "./setup_can2usb.bash" for the first-time setup and run "./bringup_can2usb.bash" to bring up the device each time you unplug and re-plug the adapter. + +### Setup UART + +Generally your UART2USB cable should be automatically recognized as "/dev/ttyUSB0" or something similar and ready for use. If you get the error "... permission denied ..." when trying to open the port, you need to grant access of the port to your user accout: + +``` +$ sudo usermod -a -G dialout +``` + +Replace "" in the above command with your Linux username. You need to re-login to get the change to take effect. + +## Basic usage of the ROS package 1. Install dependent ROS packages @@ -32,11 +82,22 @@ * Start the base node - ``` - $ roslaunch scout_bringup scout_minimal.launch - ``` +``` +$ roslaunch scout_bringup scout_minimal.launch +``` + +or (if you're using a serial port) + +``` +$ roslaunch scout_bringup scout_minimal_uart.launch +``` + * Start the keyboard tele-op node - ``` - $ roslaunch scout_bringup scout_teleop_keyboard.launch - ``` \ No newline at end of file +``` +$ 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. diff --git a/scout_base/launch/robot_model.launch b/scout_base/launch/robot_model.launch deleted file mode 100644 index dd33b58..0000000 --- a/scout_base/launch/robot_model.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/scout_base/launch/scout_base.launch b/scout_base/launch/scout_base.launch index 2d368bf..c2889c0 100644 --- a/scout_base/launch/scout_base.launch +++ b/scout_base/launch/scout_base.launch @@ -1,10 +1,22 @@ + + + + - + + - - diff --git a/scout_base/launch/view_scout_model.launch b/scout_base/launch/view_scout_model.launch new file mode 100644 index 0000000..305cba6 --- /dev/null +++ b/scout_base/launch/view_scout_model.launch @@ -0,0 +1,6 @@ + + + + + + diff --git a/scout_base/src/scout_base_node.cpp b/scout_base/src/scout_base_node.cpp index e770c5e..a3b7e05 100644 --- a/scout_base/src/scout_base_node.cpp +++ b/scout_base/src/scout_base_node.cpp @@ -16,18 +16,28 @@ int main(int argc, char **argv) ros::init(argc, argv, "scout_odom"); ros::NodeHandle node(""), private_node("~"); - // instantiate a robot + // instantiate a robot object ScoutBase robot; ScoutROSMessenger messenger(&robot, &node); - std::string scout_can_port; - private_node.param("port_name", scout_can_port, std::string("can0")); + // fetch parameters before connecting to robot + std::string port_name; + private_node.param("port_name", port_name, std::string("can0")); private_node.param("odom_frame", messenger.odom_frame_, std::string("odom")); private_node.param("base_frame", messenger.base_frame_, std::string("base_link")); private_node.param("simulated_robot", messenger.simulated_robot_, false); - // connect to scout and setup ROS subscription - robot.Connect(scout_can_port); + // connect to robot and setup ROS subscription + if (port_name.find("can") != std::string::npos) + { + robot.Connect(port_name); + ROS_INFO("Using CAN bus to talk with the robot"); + } + else + { + robot.Connect(port_name, 115200); + ROS_INFO("Using UART to talk with the robot"); + } messenger.SetupSubscription(); // publish robot state at 20Hz while listening to twist commands diff --git a/scout_bringup/CMakeLists.txt b/scout_bringup/CMakeLists.txt index 1111d33..ca0910b 100644 --- a/scout_bringup/CMakeLists.txt +++ b/scout_bringup/CMakeLists.txt @@ -154,7 +154,7 @@ include_directories( ## Install ## ############# -install(DIRECTORY launch +install(DIRECTORY launch scripts DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) diff --git a/scout_bringup/launch/scout_minimal.launch b/scout_bringup/launch/scout_minimal.launch index dcf7dd8..22c94b2 100644 --- a/scout_bringup/launch/scout_minimal.launch +++ b/scout_bringup/launch/scout_minimal.launch @@ -1,3 +1,6 @@ - + + + + \ No newline at end of file diff --git a/scout_bringup/launch/scout_minimal_uart.launch b/scout_bringup/launch/scout_minimal_uart.launch new file mode 100644 index 0000000..c1e46cb --- /dev/null +++ b/scout_bringup/launch/scout_minimal_uart.launch @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/scout_bringup/scripts/bringup_can2usb.bash b/scout_bringup/scripts/bringup_can2usb.bash new file mode 100755 index 0000000..e638f6a --- /dev/null +++ b/scout_bringup/scripts/bringup_can2usb.bash @@ -0,0 +1,4 @@ +#!/bin/bash + +# bring up can interface +sudo ip link set can0 up type can bitrate 500000 \ No newline at end of file diff --git a/scout_bringup/scripts/setup_can2usb.bash b/scout_bringup/scripts/setup_can2usb.bash new file mode 100755 index 0000000..6a8d891 --- /dev/null +++ b/scout_bringup/scripts/setup_can2usb.bash @@ -0,0 +1,10 @@ +#!/bin/bash + +# enable kernel module: gs_usb +sudo modprobe gs_usb + +# bring up can interface +sudo ip link set can0 up type can bitrate 500000 + +# install can utils +sudo apt install -y can-utils \ No newline at end of file