... | ... | @@ -110,29 +110,146 @@ This should show a window that looks like this: |
|
|
|
|
|
![rviz_final](uploads/77a697f1e5267c9b0bb23589c0241637/rviz_final.png)
|
|
|
|
|
|
You can save your Rviz configuration from the file menu.
|
|
|
|
|
|
Send command to the robot
|
|
|
-------------------------
|
|
|
|
|
|
The robot is ready to take command.
|
|
|
The robot is ready to take command. The first commands you can send to the robot are for docking and undocking, in a terminal:
|
|
|
|
|
|
```bash
|
|
|
ros2 action send_goal /navigate_to_position irobot_create_msgs/action/NavigateToPosition "{achieve_goal_heading: true,goal_pose:{pose:{position:{x: 1,y: 4,z: 0.0}, orientation:{x: 0.0,y: 0.0, z: 0.0, w: 1.0}}}}"
|
|
|
ros2 action send_goal /dock irobot_create_msgs/action/DockServo {}
|
|
|
ros2 action send_goal /undock irobot_create_msgs/action/Undock {}
|
|
|
```
|
|
|
|
|
|
ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose "pose: {header: {frame_id: map}, pose: {position: {x: 6.0, y: 2.0, z: 0.0}, orientation:{x: 0.0, y: 0.0, z: 0, w: 1.0000000}}}"
|
|
|
The following action can be used to make the robot move forward by a given velocity:
|
|
|
|
|
|
ros2 action send_goal /dock irobot_create_msgs/action/DockServo {}
|
|
|
ros2 action send_goal /undock irobot_create_msgs/action/Undock {}
|
|
|
```bash
|
|
|
ros2 action send_goal /drive_distance irobot_create_msgs/action/DriveDistance "{ distance: 3.5, max_translation_speed: 0.3 }"
|
|
|
```
|
|
|
|
|
|
The following action can be used to send the robot to a specific position:
|
|
|
|
|
|
```bash
|
|
|
ros2 action send_goal /navigate_to_position irobot_create_msgs/action/NavigateToPosition "{achieve_goal_heading: true,goal_pose:{pose:{position:{x: 3, y: 4,z: 0.0}, orientation:{x: 0.0,y: 0.0, z: 0.0, w: 1.0}}}}"
|
|
|
```
|
|
|
|
|
|
Managing topics from the command line
|
|
|
-------------------------------------
|
|
|
|
|
|
The main communication medium for ROS is through the using of _topics_. Topics have a name and a type and follow a publisher-subscriber pattern. You can use the following command to list all available topics:
|
|
|
|
|
|
|
|
|
```bash
|
|
|
ros2 topic list
|
|
|
```
|
|
|
|
|
|
If you want detailed information about a topic, to know the type and which nodes are subscribed/publishing:
|
|
|
|
|
|
ros2 topic info -v /cmd_vel
|
|
|
|
|
|
You can listen to a topic from the command line to get the values:
|
|
|
|
|
|
```bash
|
|
|
ros2 topic echo /odom
|
|
|
```
|
|
|
|
|
|
To check what is happening, run one of the command of the previous section and you should see the position of the robot on the terminal.
|
|
|
|
|
|
And finally you can publish on a topic:
|
|
|
|
|
|
```bash
|
|
|
ros2 topic pub --rate 100 /cmd_vel geometry_msgs/msg/Twist "{ linear: { x: 0.4, y: 0.0, z: 0.0}, angular: { x: 0.0, y: 0.0, z: 0.3 } }"
|
|
|
```
|
|
|
|
|
|
After that command, you should be able to see the robot move in circle in RViz or the simulator window. You should also be able to see the position changed when listening to ```/odometry```.
|
|
|
|
|
|
RQT
|
|
|
---
|
|
|
|
|
|
An alternative approach to use the command line for listening or publishing on topics is to use a tool called RQT. You can start it from the command line simply with:
|
|
|
|
|
|
Path Planning and obstacle avoidance
|
|
|
------------------------------------
|
|
|
```bash
|
|
|
rqt
|
|
|
```
|
|
|
|
|
|
Then in the interface, from the plugin menu, add the following:
|
|
|
|
|
|
* ```topics > message publisher```
|
|
|
* ```topics > topic monitor```
|
|
|
* ```robot tools > robot steering``` you can then set the topic to ```/cmd_vel```.
|
|
|
|
|
|
The window should look like this:
|
|
|
|
|
|
![rqt](uploads/93ef754cc99eecd6fa9eeb1b4dfc070a/rqt.png)
|
|
|
|
|
|
If you check the ```/odom``` in topic monitor you can see it change. In the message publisher you can add new topics and set the value to publish, try to add ```/cmd_vel```and to publish the velocity. A more convenient alternative to controlling the velocity is to use the robot steering panel (do note that the robot does not like to move backward).
|
|
|
|
|
|
You can also use rqt to plot value, add a plot with ```Visualization > Plot```. You can then add ```/diffdrive_controller/cmd_vel_unstamped/linear/x``` and /diffdrive_controller/cmd_vel_unstamped/angular/z```
|
|
|
|
|
|
You should see something like this:
|
|
|
|
|
|
![rqt_plot](uploads/4789982040a3f366345e47c4d930e8e5/rqt_plot.png)
|
|
|
|
|
|
screen
|
|
|
------
|
|
|
|
|
|
As you can see, we ended up starting a lot of commands from the terminal. It can be annoying to have so many windows and terminals open, a solution is to use [GNU Screen](https://www.gnu.org/software/screen/), which allows to start all the processes in a single terminal window.
|
|
|
|
|
|
The easiest way to use it is to create a screen configuration file (you can call it ```screen.tdde05```):
|
|
|
|
|
|
```
|
|
|
# Configuration
|
|
|
deflogin on
|
|
|
autodetach off
|
|
|
|
|
|
caption always
|
|
|
|
|
|
bindkey ^w screen
|
|
|
bindkey ^p prev
|
|
|
bindkey ^n next
|
|
|
bindkey ^x quit
|
|
|
bind q quit
|
|
|
bindkey ^l windowlist
|
|
|
bindkey ^e copy
|
|
|
|
|
|
# Pre-defined tabs
|
|
|
|
|
|
screen 0
|
|
|
title "simple sim"
|
|
|
stuff "start-tdde05; ros2 launch air_bringup turtle.launch.py\015"
|
|
|
|
|
|
screen 2
|
|
|
title "rviz"
|
|
|
stuff "start-tdde05; rviz2\015"
|
|
|
|
|
|
screen 3
|
|
|
title "rqt"
|
|
|
stuff "start-tdde05; rqt\015"
|
|
|
```
|
|
|
|
|
|
You can then start it from a terminal with ```screen -c screen.tdde05```.
|
|
|
|
|
|
The following shortkeys can be used:
|
|
|
|
|
|
* ```ctrl+w``` to create a new command tab
|
|
|
* ```ctrl+p``` to navigate to the previous tab
|
|
|
* ```ctrl+n``` to navigate to the next tab
|
|
|
* ```ctrl+x``` to quit
|
|
|
* ```ctrl+l``` to show the list of tabs
|
|
|
* ```ctrl+e``` to scroll in the log, using up/down arrow (page up/down works as well), press \verb|ESC| to stop scrolling
|
|
|
\end{itemize}
|
|
|
|
|
|
In the screen configuration file:
|
|
|
* ```screen 12``` indicates a new tab with number ```12```
|
|
|
* ```title``` indicates the name of the tab (as shown in the list of tabs)
|
|
|
* ```stuff``` indicates the command that is run in the tab, the ```\015``` at the end indicates whether the command is ran when starting the screen or if you have to start it manually
|
|
|
|
|
|
As an exercise, adds tab for the action of docking, undocking and moving to a location (do not add ```\015``` at the end of the command line, to make sure you don't start those action every time you start the screen file).
|
|
|
|
|
|
Demonstration
|
|
|
-------------
|
|
|
|
|
|
* Show your ```screen``` file
|
|
|
* Use ```rviz``` and ```rqt```, to show how your robot respond to docking, undocking and moving to a location.
|
|
|
|