After saving the edited node, bringup [Stretch in the empty world simulation](gazebo_basics.md). To drive the robot with the node, type the follwing in a new terminal
```
cd catkin_ws/src/stretch_ros_turotials/src/
```bash
cd catkin_ws/src/stretch_ros_tutorials/src/
python3 move.py
```
To stop the node from sending twist messages, type **Ctrl** + **c**.
The aim of example 3 is to combine the two previous examples and have Stretch utilize its laser scan data to avoid collision with objects as it drives forward.
Begin by running `roscore` in a terminal. Then set the ros parameter to *navigation* mode by running the following commands in a new terminal.
Begin by running `roscore` in a terminal. Then set the ros parameter to *manipulation* mode by running the following commands in a new terminal.
```bash
rosparam set /stretch_driver/mode "navigation"
# Terminal 1
rosparam set /stretch_driver/mode "manipulation"
roslaunch stretch_core stretch_driver.launch
```
Then in a new terminal type the following to activate the LiDAR sensor.
```bash
# Terminal 2
roslaunch stretch_core rplidar.launch
```
To activate the avoider node, type the following in a new terminal.
```bash
cd catkin_ws/src/stretch_ros_turotials/src/
# Terminal 3
cd catkin_ws/src/stretch_ros_tutorials/src/
python3 avoider.py
```
To stop the node from sending twist messages, type **Ctrl** + **c** in the terminal running the avoider node.
@ -35,7 +38,15 @@ from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
class Avoider:
"""
A class that implements both a LaserScan filter and base velocity control
for collision avoidance.
"""
def __init__(self):
"""
Function that initializes the subscriber, publisher, and marker features.
:param self: The self reference
"""
self.pub = rospy.Publisher('/stretch/cmd_vel', Twist, queue_size=1) #/stretch_diff_drive_controller/cmd_vel for gazebo
the `rviz` flag will open an RViz window to visualize a variety of ROS topics. In a new terminal run the following commands to create a marker.
```bash
cd catkin_ws/src/stretch_ros_turotials/src/
# Terminal 2
cd catkin_ws/src/stretch_ros_tutorials/src/
python3 marker.py
```
The gif below demonstrates how to add a new *Marker* display type, and change the topic name from `visualization_marker` to `balloon`. A red sphere Marker should appear above the Stretch robot.
@ -26,7 +28,14 @@ import rospy
from visualization_msgs.msg import Marker
class Balloon():
"""
A class that attaches a Sphere marker directly above the Stretch robot.