ROS实战

xiaoxiao2021-02-28  134

0. Package Summary

    Information from the robot base, and velocity and acceleration control, is implemented via a RosAria node, which publishes topics providing data recieved from the robot's embedded controller by ARIA, and sets desired velocity, acceleration and other commands in ARIA when new commands are received from command topics.

Source: git https://github.com/amor-ros-pkg/rosaria.git (branch: master)

0.1 ROS API

    ROS topics are channels by which other nodes can communicate with ROSARIA by sending or reading messages. For more information on ROS topics, see Topics and rostopic.

    ROS services are channels by which other nodes can cause specific events to occur on the robot via ROSARIA. For more information on services, see Services and rosservice.

    Parameters are used to configure the behavior of the RosAria node during initial startup of the node, such as how to connect to the robot controller. They may be set on the command line when running rosrun or in a launch file when using roslaunch. Parameters are stored by the ROS parameter server. See also Parameter Server, rosparam, rosrun and roslaunch.

    Some parameters can also be dynamically changed using dynamic_reconfigure.

0.2 RosAria

Simple node that uses ARIA to control the robot

    Subscribed Topics:

cmd_vel (geometry_msgs/Twist)

receives new velocity commands. Desired velocities are set in ARIA; the robot will achieve and maintain these velocities. ARIA will continue to send the velocity commands to the robot controller, but if no cmd_vel messages are received after 600ms (configurable or disabled via cmd_vel_timeout parameter, see below), rosaria will stop the robot. So cmd_vel commands are only needed to change velocity, or to to reset the watchdog timeout.

    Published Topics:

pose  ( nav_msgs/Odometry ) publishes odometry information (rate depends on the robot, normally 10Hz) bumper_state  ( rosaria/BumperState ) publishes bumper states (thanks to Arturo Ribes of the Spanish National Research Council) sonar  ( sensor_msgs/PointCloud ) publishes sonar readings (thanks to Michiel Blokzijl of the Imperial College London). Readings are taken if there are subscribers on the topic. When the last subscriber unsubscribes from both this and sonar_pointcloud2 topic, sonars are turned off. Only available on robots with sonar. The point cloud is two dimensional, and its coordinate frame matches the robot position. X and Y are points on the plane of the robot. Z data is always 0. sonar_pointcloud2  ( sensor_msgs/PointCloud2 ) publishes sonar readings as sensor_msgs/PointCloud2 type. Readings are taken if there are subscribers on the topic. When the last subscriber unsubscribes from both this and sonar topic, sonars are turned off. Only available on robots with sonar. The point cloud is two dimensional, and its coordinate frame matches the robot position. X and Y are points on the plane of the robot. Z data is always 0. battery_state_of_charge  ( std_msgs/Float32 ) Battery state-of-charge percentage, range (0.0, 1.0). Only published if robot type supports state of charge (e.g. Pioneer LX, Seekur, Seekur Jr.) battery_voltage  ( std_msgs/Float64 ) Battery voltage measurement (DC volts). battery_recharge_state  ( std_msgs/Int8 ) Recharging status. Only published on Pioneer LX robot. 0 if not charging, > 0 if recharging, and < 0 on error or no data. motors_state  ( std_msgs/Bool ) Indicates whether the motors are enabled (true) or disabled (false). (You can use the enable_motors and disable_motors services to enable/disable the motors.) <lasername>_pointcloud  ( sensor_msgs/PointCloud ) Only published if publish_aria_lasers parameter is true. Provides laser data as a point cloud. <lasername> will be ARIA's identifier for the laser. May be repeated with different laser names if multiple lasers are configured in ARIA robot parameter file(s). <lasername>_laserscan  ( sensor_msgs/LaserScan ) Only published if publish_aria_lasers parameter is true. Provides laser data as a laserscan type. <lasername> will be ARIA's identifier for the laser. May be repeated with different laser names if multiple lasers are configured in ARIA robot parameter file(s).

    Services:

enable_motors  ( std_srvs/Empty ) Enable the motors. May be used to re-enable motors if automatically disabled by an event such as e-stop button or bumper hit. ROSARIA initially enables the motors after connecting to the robot. Some robots (Seekur, Seekur Jr.) also have a separate physical MOTORS switch that must also be turned on. disable_motors  ( std_srvs/Empty ) Disable motors. Depending on the robot this may just disable motion commands, or it may also switch off power to the motors. Use the enable_motors service to re-enable them.

    Parameters:

~port  ( string , default: /dev/ttyUSB0) Serial port device the robot is is connected to, or a hostname and TCP port separated by a colon to do TCP communications (e.g 10.0.126.32:8101). Set to /dev/ttyS0 for onboard computers with direct serial connection via COM1 serial port . Set to /dev/ttyUSBx for use with a USB-serial adapter, where x is the appropriate interface index. (Use /dev/ttyS0 with onboard computer as installed by AMR in normal configuration, except Pioneer LX, which uses /dev/ttyUSB0) ~baud  ( int , default: Use ARIA default (internal defaults,  /etc/Aria.args file  if present, and  ARIAARGS  environment variable if set)) Explicit serial Baud rate. All robots should use 9600 (unless explicitly set in firmware configuration) except Pioneer LX which uses 57600. ARIA may switch to a higher baud rate if possible after connecting. ~debug_aria  ( bool , default: false) If given, ARIA logging is set to Verbose level, ARIA log output is redirected to a file (see ~aria_log_filename), and additional robot-communications logging is turned on (Note, this will generate lots of data, >100 log messages per second) ~aria_log_filename  ( string , default: Aria.log) ARIA log file if ~debug_aria is set to true. Unused if ~debug_aria is set to false. ~publish_aria_lasers  ( bool , default: false) If true, then RosAria will use ARIA to connect to any lasers configured in [ARIA robot parameter files|http://robots.mobilerobots.com/wiki/ARIA_and_ARNL_Robot_Parameters] and publish two topics for each laser: one with PointCloud data, the other with LaserScan data (see above). The topics will be named based on ARIA identifiers. (E.g. for a p3dx-sh-lms1xx robot with an LMS100 configured as Laser 1 in the ARIA robot parameter file (p3dx-sh-lms1xx.p), the topics lms1XX_1_pointcloud and lms1XX_1_laserscan will be published.) See also http://robots.mobilerobots.com/wiki/How_ARIA_Connects_To_Lasers. This feature is disabled by default. If not using this feature, use separate ROS nodes to provide laser data.

Note: 更多命令详见原网页

0.3 Examples

Video Walkthroughs including how to build and run some example client programs are available at /Tutorials/Video Walkthroughs

Examples that use RosAria to teleoperate a Pioneer from mobile phones are available at /Tutorials/iPhone Teleop With ROSARIA and /Tutorials/Android teleop Pioneer 3at

1. Create your ROS workspace

     If you have not yet created your ROS overlay workspace in your home directory, do so now. Set up your shell environment, so that some ROS-specific commands are available:

. /opt/ros/indigo/setup.bash

    Create a catkin workspace. (Your workspace directory may have any name, catkin_ws is used here as an example, but you may use a different name if you wish.)

mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src catkin_init_workspace cd ~/catkin_ws catkin_make

    Note:catkin_init_workspace must be run inside the src subdirectory, but catkin_make is used in the parent workspace directory. catkin_init_workspace only needs to be done once in the src directory.

    You can setup separate workspaces for different versions of ROS if more than one is installed.--so usually you just need to create one workspace!

2. Source setup.bash

     Every time you want to use the catkin workspace to build packages, you must source the special devel/setup.bash script

cd catkin_ws . devel/setup.bash

    You must do this for every new shell or terminal window you open.

    ROS下的操作依赖于一种工作空间的概念,因此,这是文件系统最上层,如果你要在此工作空间下进行操作,每次打开一个终端都要source 一下对应工作空间下的 devel/setup.bash文件。一般来说,一段时间内只会进行某个项目的操作,因此每次都会在某个工作空间下进行操作,因此可以

    If you only use one catkin workspace, you can add this command to your .bashrc file, so that it automatically occurs for every new shell or terminal window you run.

    For example, if your catkin workspace is catkin_ws in your home directory, edit .bashrc in your home directory and add the following line to the end of the file. The .bashrc file is normally hidden, but you can still reference it to edit it or enable "Show hidden files" in the file browser preferences.

. ~/catkin_ws/devel/setup.bash

    Note:The .bashrc file is normally hidden, ctrl + h 显示隐藏的文件

    If you have multiple catkin workspaces for multiple versions of ROS, you must source the setup file from inside the workspace you want to use.

    查看当前工作空间:echo $ROS_PACKAGE_PATH

3. Bring ROSARIA into the workspace

    Next you will need to download the rosaria source code from its repository.

cd ~/catkin_ws/src git clone https://github.com/amor-ros-pkg/rosaria.git

4. Install ARIA and Build ROSARIA

    RosAria uses the Aria library from Adept MobileRobots to communicate with the robot.

    To install the latest version of ARIA, download it from http://robots.mobilerobots.com/wiki/Aria. If you are using Ubuntu 16.04 or later, install the package indicated for Ubuntu 16 or later. If you are using a previous version of Ubuntu (12.04 or later), install the package indicated for Ubuntu 12.

    Note: rosaria's CMake build script detects the location of the ARIA library when catkin runs cmake. If you have already tried building rosaria prior to installing the ARIA library (either via rosdep or manually), you must force catkin to re-run cmake for rosaria with catkin_make --force-cmake. Do this if you get errors while building rosaria such as "could not find such file or directory : Aria/Aria.h" or siimlar.

    Now build rosaria using catkin. Run this from your catkin workspace directory:

catkin_make

This will build all packages in the catkin workspace. You only need to install and build ROSARIA once, or when changing to new versions of ROSARIA or ARIA.

5. Run roscore

    Next, we can start the RosAria node. First, run roscore from your ros workspace, if you have not done so already:

roscore

    roscore must always be running for any other ROS node in this ROS node network to work and communicate. It only needs to run once, however, you don't need to run it every time you restart RosAria.

    If you are running different nodes on different computers, only one roscore is needed, but its hostname (address) must be specified when running nodes on other computers. The RosAria node must run on a computer connected to the robot controller -- either the robot's (primary) onboard computer, or a laptop connected via serial connector to the robot HOST serial port.

6. Run the RosAria node

    Next, run the RosAria node from the rosaria package.

If necessary, open a new terminal window. If you have not yet done so in this terminal windows or shell, and you have not set up your .bashrc file to do so automatically, source the catkin setup script in your workspace:

cd catkin_ws . devel/setup.bash

    Unless the computer running RosAria has a DNS entry that client programs and other nodes can use to locate it, you must also set the ROS_IP environment variable before running RosAria. 

    Normally ROS provides the local computer's hostname to other nodes, but if they cannot use this hostname, then they will not be able to connect to the RosAria node. The ROS_IP environment variable explicitly specifies the IP address to use. 

    For example, if your computer has IP address 10.0.126.32 set ROS_IP as follows before running RosAria:

Note: 使用 ifconfig 查看本机ip地址;

export ROS_IP=10.0.126.32

    Substitute the correct IP address if different. If you are using a wireless network, use the IP address for the wireless ethernet interface (usually wlan0, wifi0, or ath0).

Next, run the RosAria node:

Note:一般需要先运行此命令,否则检测不到端口;

sudo chmod 777 -R /dev/ttyUSB0 rosrun rosaria RosAria

    The first argument to rosrun specifies the package name, "rosaria". The second argument to rosrun specifies the node name, "RosAria".

Additional parameters may be set via rosrun. See below for details.

    If you receive an error regarding connecting to the robot on port /dev/ttyUSB0 or similar, you may need to specify a different port via the ~port parameter. See the section below on "RosAria Parameters" for more information.

    Only one program can connect to the robot at a time, so only one instance of the rosaria node (or any other program connected to the robot, such as one of the demo/example/server programs provided with ARIA or ARNL, or the p2os node) can run at a time.

    Note, if you run roscore on a different computer, set the ROS_MASTER_URI environment variable first to reference that        roscore    server. 

   For example, if you run roscore on a computer with address 10.0.100.1, set it like this:

export ROS_MASTER_URI=http://10.0.100.1:11311

    You must also set ROS_MASTER_URI before running any other nodes or   client   programs on computers other than the computer running roscore.

7. RosAria Parameters

    RosAria has a port parameter that specifies which serial port to use to connect to the robot, or it may contain a hostname and TCP port to connect remotely over TCP (for example, to connect to an AmigoBot or other robot that uses a wifi serial-bridge or to to a MobileSim simulator running on a different host.) 

    The port parameter may be given on the command line when running the RosAria node with rosrun, or it may be changed     using rosparam (before staring RosAria, or restart RosAria.) The value will be saved in the ROS parameters and reused next time you run RosAria.

    The default port is /dev/ttyUSB0, which will work if you have connected your Linux laptop or other computer to the robot via a USB-serial adapter, and also on the Pioneer LX which uses USB-serial adapters:

rosrun rosaria RosAria

    To specify the port as /dev/ttyS0 (COM1, normal for most robot onboard computers) instead, use:

rosrun rosaria RosAria _port:=/dev/ttyS0

    Make sure you have added your user to the "dialout" group : sudo usermod -a -G dialout $USER, 

    or change the permissions of the serial port device to allow all users to access it     

    e.g. sudo chmod a+rw /dev/ttyUSB0 

    or sudo chmod a+rw /dev/ttyS0). 

    You can check the Linux kernel logs by running dmesg after plugging in the USB-serial converter to see the name of the device interface being used.

    If you have a robot with a wireless ethernet-serial bridge device with IP address 10.0.126.32, use the following command instead:

rosrun rosaria RosAria _port:=10.0.126.32:8101

    If using the onboard computer on a Pioneer 3, Pioneer 2, PeopleBot, PowerBot or PatrolBot, use /dev/ttyS0 as in the example above. IF you are using the embedded computer in a Pioneer LX, use /dev/ttyUSB0.

    Note that only one instance of the RosAria node may run at one time, stop any other RosAria instances before running a new one.

In addition to the port parameter, RosAria also accepts other parameters as well. See ROSARIA for a full list.

    Note: When you specify a parameter using rosrun, the ROS parameter system automatically stores this setting for future use, and will use the previously set value if the parameter is omitted. Specify a new value to change.

8. Example Client Programs

    An example set of client programs with a text-based interactive interface for running them is available from https://github.com/pengtang/rosaria_client. 

    Read the README file for instructions. These example programs show how to publish or subscribe to ROSARIA's topics, and can be used to interactively test or demonstrate ROSARIA controlling the robot.

9. Launch files and other configuration

    A set of configuration files including roslaunch files, URDF, etc is available from http://github.com/MobileRobots/amr-ros-config

10. Using MobileSim simulator

    MobileSim is a simulator for use with ARIA. It provides a simple 2D simulation scalable to many robots, and useful for software testing. (It is actually based on Stage version 2.)

    ARIA automatically detects MobileSim if it is running on the same computer, and will connect to it. Or, you can explicitly set it using RosAria's ~port parameter:

rosrun rosaria RosAria _port:=localhost:8101

 Note:   当你想在仿真环境下同时连接多个机器人时:

(1)只需要将RosAria复制多份,并分别命名为 RosAria1,RosAria2... main函数做对应的名称修改; 

(2)启动 mobile sim 时启动多个;

(3)分别运行对应的节点时加上参数;

rosrun rosaria RosAria _port:=localhost:8101 rosrun rosaria RosAria _port:=localhost:8102  ...

或手动启动mobilesim后直接运行节点即可。    

    MobileSim will emulate the robot base (i.e. velocity commands from the cmd_vel topic and a position estimate given via poseor odom topics -- see below) and sonar (sonar topic -- see below), but connection to other devices such as laser, camera, etc. are through separate nodes in ROS and cannot currently be connected to MobileSim.

    For more full-featured simulation in ROS, use stdr_simulator, Stage or Gazebo instead.

11. Topics and Commands

    RosAria provides several topics for publishing information received from the robot and devices by ARIA, and for receiving commands. These follow ROS conventions and use standard ROS datatypes and units. For example, it uses a "twist" for velocity commands, even though only some components apply to differential drive ground mobile robots, and units are translated to meters and radians as used in ROS from the millimeters and degrees used by the robot and ARIA.

11.1 Pose

    RosAria publishes the current pose estimation received from the robot in /RosAria/pose. The type of this data is nav_msgs/Odometry. (This pose estimation is calculated by the robot firmware as ARIA based on wheel odometry, and if preset, the optional internal gyroscope.)

    This pose estimation is received from the robot every 100ms (by default), and is then published on the /RosAria/pose topic.

    To view /RosAria/pose using rostopic use:(前提是已启动节点,与机器人建立连接)

rostopic echo /RosAria/pose

    Press Ctrl-C to stop.

11.2 Velocity Commands

    The desired velocity of the robot is set via the /RosAria/cmd_vel topic. This desired velocity state is set in ARIA, which sends commands every robot cycle (100ms by default) to effect this state in the robot's embedded motion controller, which performs motor control to achieve then maintain the robot velocity automatically (using previously configured acceleration parameters).

    You do not need to send commands at any fixed rate to maintain robot velocity, ARIA and the robot controller maintain the velocities. Velocity commands only need to be sent to change the desired velocities.

    A standard type for robot motion commands in ROS is geometry_msgs/Twist, which contains many components (dimensions). The relevant twist components for Pioneer mobile robots are linear x (forward/back translational velocity) and angular z (rotational velocity). (In future, the Seekur robot will accept linear y for lateral velocity as well.)

    The syntax for specifying twist data using the rostopic command is as follows (this example sets a linear velocity of 0.1 meters/s):

rostopic pub -1 /RosAria/cmd_vel geometry_msgs/Twist '[0.1, 0.0, 0.0]' '[0.0, 0.0, 0.0]'

11.3 Sonar

   RosAria also provides the /RosAria/sonar topic for sonar readings. The type of this topic is a 2-dimensional sensor_msgs/PointCloud.

11.4 Enable/Disable Motors

    Whether the robot's motors are enabled or disabled is published as a boolean value via the /RosAria/motors_state topic.

To enable the motors, use the /RosAria/enable_motors service. To disable the motors, use the /RosAria/disable_motorsservice.

RosAria enables the motors when it connects to the robot, but some robots require motors to be explicitly re-enabled after the e-stop button is pressed (e.g. Pioneer LX) or a bumper hit occurs (e.g. Seekur).

11.5 Other Topics

Other topics may be added in the future as well.

See ROSARIA for the current, complete list.

12. Acceleration Parameters

    Acceleration and deceleration parameters may be adjusted via dynamic_reconfigure: trans_accel, trans_decel, rot_accel, rot_decel, lat_accel, lat_decel. These are sent to the robot controller and it will use them as soon as any requested velocity changes to achieve that change in velocity.

转载请注明原文地址: https://www.6miu.com/read-17922.html

最新回复(0)