Rviz plugins package for handling custom info and operations. currently there are several plugins:
The Battery shows the battery's left charge in text and symbolizes the battery; the Navi_waypoints allows user to add multiple navigation targets with interactive markers; the Teleop which publishes the twist message through GUI; the panel Map_saver helps user to save map directly by RViz without typing command in terminal; the Video_stream which derived from default image plugin with extended stream sources like webcam, IP stream, and video file; the tool Navi_namespace, under multiple robots scenario, allows user to specify target robot target through GUI without laboring edit in tool property; the Navi_robot_model_viewer is an auxiliary OGRE view for showing the URDF of robot
Referring build section for setup the package:
Following the brief introduction for the usage of each plugin:
- Use Battery
- Use Navi_waypoints
- Use Teleop
- Use Map_saver
- Use Video_stream
- Use Navi_namespace
- Use Navi_robot_model_viewer
Plugin Battery is a derived class from MessageFilterDisplay:
It subscribes message "whi_interfaces::WhiBattery". Here is the definition of such message:
std_msgs/Header header
uint16 soc
uint8 STA_NORMAL=0
uint8 STA_CHARGING=1
uint8 STA_NEED_CHARGING=2
int8 state
The base of the charge text will be at the frame listed in the header of the WhiBattery message, which lets the charge info stick to the robot and move with it. Besides under multiple robots scenario, frame with namespace enables each robot to bear its charge info.
Plugin Navi_waypoints derives from class rviz::Display, and creates a panel for waypoints interaction logic:
From version 00.09 it supports the namespace for manipulating multiple robots simultaneously:
Teleop's function is the same as the one operated through terminal but with graphic interaction which can be more convenient in scenario like mapping. User can navigate the robot directly through the mapping's RViz window without opening another terminal:
Map_saver is a panel type plugin. It can help user to save map directly through the mapping's RViz window without typing save commands in another terminal:
This plugin derived from the default image plugin with extended stream sources including webcam, IP stream, and video file:
This plugin derived from the PoseTool, and extended to functionalities with both 2D Pose Estimate and 2D Nav goal. With this plugin user can navigate specified robot by GUI rather than laborious texting by Tool Properties:
This plugin is an additional OGRE view for showing the URDF of robot, which is requested by our end-user. It is derived from rviz::Display with user interaction in the 3D scene:
Clone package whi_interfaces
and whi_rviz_plugins
to your workspace:
cd <your_workspace>/src
git clone https://github.com/xinjuezou-whi/whi_interfaces.git
git clone https://github.com/xinjuezou-whi/whi_rviz_plugins.git
cd ..
catkin build
or catkin_make
depends on your environment. And don't forget to source the bash:
source <your_workspace>/devel/setup.bash
- Publish the WhiBattery message
For a quick check, there is a test script, named send_test_msgs.py
under folder scripts
to publish simulated charge info interactively. Before running it, please make sure roscore is active:
roscore
and open a new terminal and run:
python src/whi_rviz_plugins/scripts/send_test_msgs.py
- Run RViz to add the Battery plugin
Click the "Add" button at the bottom of the "Displays" panel, then scroll down through the available displays until you see "Battery" under package name "whi_rviz_plugins":
Once the Battery display is added to RViz, set the topic name of the display to a source of "whi_interfaces::WhiBattery". The topic is "test_bat" if you are running the "send_test_msgs.py".
Modify the offsets to the center of frame to adjust its local position:
Modify the orientation to the frame to adjust the direction of the battery symbol, this is helpful in navigation scenario which is a 2D view of XY plane:
Navigation robot should have a static TF link that directs to map. The below gif shows the static TF in robot's URDF(battery->base_link->map)
- Add the Navi_waypoints plugin to RViz
Click the "Add" button at the bottom of the "Displays" panel, then scroll down through the available displays until you see "Navi_waypoints" under package name "whi_rviz_plugins":
- Add waypoints and adjust its position and orientation through interactive marker
Remember to switch the mode from "Move Camera" to "Interact" to grand the accessibility of waypoint marker
- Click "Execute" to start the multiple goal's navigation
Since the view orientation is top-down in navigation, multiple info are projected on map and overlay each other. If the interactive marker is happen to be overlaid by other info, it could not be accessed by user. Therefore the property marker height is introduced to make sure it is on top of other info, so to be accessible.
It is suggested to set its height over the max of your robot, the default is 1 meter
These two params on Navi_waypoints panel are used to set the duration between two adjacent goals. If the execution is set as loop mode, the stop span stands for the duration between the last goal and the first goal.
The duration is measured as time, so these two's units are second. Both are within range -10800 to 10800. Negative duration means there is no stop between goals, and the current goal will be preempted x seconds ahead its arrival by the next goal. The positive means the stop duration between goals.
For convenience, you can save the waypoints by clicking the save button, and re-use them by button load. The waypoints file is saved in yaml format.
Under multiple robots scenario, using the namespace drop list to set the namespace for specified robot.
- Add the Navi_waypoints plugin to RViz
Click the "Add" button at the bottom of the "Displays" panel, then scroll down through the available displays until you see "Teleop" under package name "whi_rviz_plugins":
- click direction buttons or press keys to navigate the robot
keys definition
Keys are functional while the "Key" indicator is light on in green. If it is gray click the anywhere of the teleop panel to activate it.
This property toggles the publish of twist message. It is helpful to avoid the collision of cmd_vel while the plugin is added in navigation's configuration.
Add the Teleop panel by opening the "Panels" menu and then "Add New Panel" within that. This should bring up a Panel class chooser dialog, and select the "Map_saver" within whi_rviz_plugins":
Once the map is satified to you, just click the "Save" button to save it:
- Add the Video_stream plugin to RViz
Click the "Add" button at the bottom of the "Displays" panel, then scroll down through the available displays until you see "Video_stream" under package name "whi_rviz_plugins":
- Specify the stream source
Source | Type | Example |
---|---|---|
Message | sensor_msgs::Image | ROS default image message |
Device | webcam | /dev/video1, just input the index of video device, like 1 in this example |
URL | IP video stream or video file | rtsp://xxxx or http://xxxx or https://xxxx and even a video file like /home/user/xxxx.mp4 |
- Add the Navi_namespace plugin to RViz
Click the "+" icon at the toolbar, then scrolling down through the available tools until your see "Navi_namespace" under package name "whi_rviz_plugins":
- Add namespace
Input namespace in combox, then click button "Add". If namespace is added successfully, the Navi_namespace panel will show the total count of added namespaces:
- Toggle between Initial Pose and Navi Goal for setting the initial pose and sending out the navigation goal:
NOTE: In a multi-machine operating environment, the timestamps between different machines need to be synchronized. Otherwise, there may be situations where executing navigation commands fails, as shown in the following example: the left image is the timestamp of the master, and the right image is the timestamp of the client. The master time is about 2 minutes ahead of the client time:
When using the Navi_waypoints plugin in the master to perform multi-point path navigation operations, the current target timestamp recorded in the robot's actionlib is the current time of the master. If a navigation target operation is sent again using 2D Navi Goal (whether from the master or the client itself), navigation cannot be performed. This is because the plugin Navi_waypoints uses the simple action client to send navigation targets, and the timestamp used by this method is the master's own time. When actionlib receives the target, it will assign this target as its internal current target. On the other hand, 2D Navi Goal uses the message method with the topic move_base_simple/goal to send navigation targets. Under this method, when move_base receives the target message (type geometry_msgs::PoseStamped), it converts the target into move_base's target message move_base_msgs::MoveBaseActionGoal, and assigns its own time to it before forwarding the message to actionlib. Therefore, there may be a situation where the timestamp of the new navigation target is earlier than the current target timestamp recorded by actionlib. In this case, actionlib will consider it an invalid target and abandon its execution.
There are already plenty of well-established methods for timestamp synchronization, among them we recommend NTP. Please google it for the setting-up
- Add the Video_stream plugin to RViz
Click the "Add" button at the bottom of the "Displays" panel, then scroll down through the available displays until you see "Navi_robot_model_viewer" under package name "whi_rviz_plugins":
- Specify the frame of URDF
Usually the frame of URDF is "base_link", you can set it through the property "Fixed Frame". While the URDF is showing, user can interact the model with mouse as same as the main view of RViz: