From 371fdef164958a6e1c190a51cb3a0fe48080b75d Mon Sep 17 00:00:00 2001 From: "Alan G. Sanchez" Date: Mon, 29 Aug 2022 08:56:09 -0700 Subject: [PATCH] Fixed typos. --- example_1.md | 26 ++++++++++++-------------- example_2.md | 18 +++++++++--------- src/move.py | 4 ++-- src/scan_filter.py | 8 ++++---- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/example_1.md b/example_1.md index 38ba260..3edb527 100644 --- a/example_1.md +++ b/example_1.md @@ -12,7 +12,7 @@ Begin by running the following command in a new terminal. roslaunch stretch_core stretch_driver.launch ``` -Switch the mode to *navigation* mode using a rosservice call. Then drive the robot forward with the move node. +Switch the mode to *navigation* mode using a rosservice call. Then drive the robot forward with the `move` node. ```bash # Terminal 2 @@ -33,7 +33,7 @@ from geometry_msgs.msg import Twist class Move: """ - A class that sends Twist messages to move the Stretch robot foward. + A class that sends Twist messages to move the Stretch robot forward. """ def __init__(self): """ @@ -81,7 +81,7 @@ Every Python ROS [Node](http://wiki.ros.org/Nodes) will have this declaration at import rospy from geometry_msgs.msg import Twist ``` -You need to import rospy if you are writing a ROS Node. The `geometry_msgs.msg` import is so that we can send velocity commands to the robot. +You need to import `rospy` if you are writing a ROS [Node](http://wiki.ros.org/Nodes). The `geometry_msgs.msg` import is so that we can send velocity commands to the robot. ```python @@ -89,21 +89,20 @@ class Move: def __init__(self): self.pub = rospy.Publisher('/stretch/cmd_vel', Twist, queue_size=1)#/stretch_diff_drive_controller/cmd_vel for gazebo ``` -This section of code defines the talker's interface to the rest of ROS. `pub = rospy.Publisher("/stretch/cmd_vel", Twist, queue_size=1)` declares that your node is publishing to the /stretch/cmd_vel topic using the message type Twist. The queue_size argument limits the amount of queued messages if any subscriber is not receiving them fast enough. +This section of code defines the talker's interface to the rest of ROS. `pub = rospy.Publisher("/stretch/cmd_vel", Twist, queue_size=1)` declares that your node is publishing to the */stretch/cmd_vel* topic using the message type `Twist`. The `queue_size` argument limits the amount of queued messages if any subscriber is not receiving them fast enough. ```Python command = Twist() ``` -Make a Twist message. We're going to set all of the elements, since we -can't depend on them defaulting to safe values. +Make a `Twist` message. We're going to set all of the elements, since we can't depend on them defaulting to safe values. ```python command.linear.x = 0.1 command.linear.y = 0.0 command.linear.z = 0.0 ``` -A Twist has three linear velocities (in meters per second), along each of the axes. For Stretch, it will only pay attention to the x velocity, since it can't directly move in the y direction or the z direction. +A `Twist` data structure has three linear velocities (in meters per second), along each of the axes. For Stretch, it will only pay attention to the x velocity, since it can't directly move in the y direction or the z direction. ```python @@ -111,30 +110,29 @@ command.angular.x = 0.0 command.angular.y = 0.0 command.angular.z = 0.0 ``` -A *Twist* also has three rotational velocities (in radians per second). -The Stretch will only respond to rotations around the z (vertical) axis. +A `Twist` message also has three rotational velocities (in radians per second). The Stretch will only respond to rotations around the z (vertical) axis. ```python self.pub.publish(command) ``` -Publish the Twist commands in the previously defined topic name */stretch/cmd_vel*. +Publish the `Twist` commands in the previously defined topic name */stretch/cmd_vel*. ```Python rospy.init_node('move') base_motion = Move() rate = rospy.Rate(10) ``` -The next line, `rospy.init_node(NAME, ...)`, is very important as it tells rospy the name of your node -- until rospy has this information, it cannot start communicating with the ROS Master. In this case, your node will take on the name talker. NOTE: the name must be a base name, i.e. it cannot contain any slashes "/". +The next line, `rospy.init_node(NAME, ...)`, is very important as it tells rospy the name of your node -- until rospy has this information, it cannot start communicating with the ROS Master. **NOTE:** the name must be a base name, i.e. it cannot contain any slashes "/". -The `rospy.Rate()` function creates a Rate object rate. With the help of its method `sleep()`, it offers a convenient way for looping at the desired rate. With its argument of 10, we should expect to go through the loop 10 times per second (as long as our processing time does not exceed 1/10th of a second!) +The `rospy.Rate()` function creates a Rate object. With the help of its method `sleep()`, it offers a convenient way for looping at the desired rate. With its argument of 10, we should expect to go through the loop 10 times per second (as long as our processing time does not exceed 1/10th of a second!) ```python while not rospy.is_shutdown(): base_motion.move_forward() rate.sleep() ``` -This loop is a fairly standard rospy construct: checking the `rospy.is_shutdown()` flag and then doing work. You have to check is_shutdown() to check if your program should exit (e.g. if there is a Ctrl-C or otherwise). The loop calls `rate.sleep()`, which sleeps just long enough to maintain the desired rate through the loop. +This loop is a fairly standard rospy construct: checking the `rospy.is_shutdown()` flag and then doing work. You have to check `is_shutdown()` to check if your program should exit (e.g. if there is a **Ctrl-C** or otherwise). The loop calls `rate.sleep()`, which sleeps just long enough to maintain the desired rate through the loop. ## Move Stretch in Simulation @@ -142,7 +140,7 @@ This loop is a fairly standard rospy construct: checking the `rospy.is_shutdown(

-Using your preferred text editor, modify the topic name of the published *Twist* messages. Please review the edit in the **move.py** script below. +Using your preferred text editor, modify the topic name of the published `Twist` messages. Please review the edit in the **move.py** script below. ```python self.pub = rospy.Publisher('/stretch_diff_drive_controller/cmd_vel', Twist, queue_size=1) diff --git a/example_2.md b/example_2.md index 4b20b6b..1546f81 100644 --- a/example_2.md +++ b/example_2.md @@ -44,7 +44,7 @@ First, open a terminal and run the stretch driver launch file. roslaunch stretch_core stretch_driver.launch ``` -Then in a new terminal run the rplidar launch file from `stretch_core`. +Then in a new terminal run the `rplidar.launch` file from `stretch_core`. ```bash # Terminal 2 roslaunch stretch_core rplidar.launch @@ -82,7 +82,7 @@ from sensor_msgs.msg import LaserScan class ScanFilter: """ A class that implements a LaserScan filter that removes all of the points - that are not infront of the robot. + that are not in front of the robot. """ def __init__(self): self.width = 1.0 @@ -93,11 +93,11 @@ class ScanFilter: def callback(self,msg): """ - Callback function to deal with incoming laserscan messages. + Callback function to deal with incoming LaserScan messages. :param self: The self reference. - :param msg: The subscribed laserscan message. + :param msg: The subscribed LaserScan message. - :publishes msg: updated laserscan message. + :publishes msg: updated LaserScan message. """ angles = linspace(msg.angle_min, msg.angle_max, len(msg.ranges)) points = [r * sin(theta) if (theta < -2.5 or theta > 2.5) else inf for r,theta in zip(msg.ranges, angles)] @@ -127,7 +127,7 @@ from numpy import linspace, inf from math import sin from sensor_msgs.msg import LaserScan ``` -You need to import rospy if you are writing a ROS Node. There are functions from numpy and math that are required within this code, thus why linspace, inf, and sin are imported. The `sensor_msgs.msg` import is so that we can subscribe and publish LaserScan messages. +You need to import `rospy` if you are writing a ROS [Node](http://wiki.ros.org/Nodes). There are functions from `numpy` and `math` that are required within this code, thus why linspace, inf, and sin are imported. The `sensor_msgs.msg` import is so that we can subscribe and publish `LaserScan` messages. ```python self.width = 1 @@ -138,12 +138,12 @@ We're going to assume that the robot is pointing up the x-axis, so that any poin ```python self.sub = rospy.Subscriber('/scan', LaserScan, self.callback) ``` -Set up a subscriber. We're going to subscribe to the topic *scan*, looking for LaserScan messages. When a message comes in, ROS is going to pass it to the function "callback" automatically. +Set up a subscriber. We're going to subscribe to the topic *scan*, looking for `LaserScan` messages. When a message comes in, ROS is going to pass it to the function "callback" automatically. ```python self.pub = rospy.Publisher('filtered_scan', LaserScan, queue_size=10) ``` -`pub = rospy.Publisher("filtered_scan", LaserScan, queue_size=10)` declares that your node is publishing to the *filtered_scan* topic using the message type LaserScan. This lets the master tell any nodes listening on *filtered_scan* that we are going to publish data on that topic. +`pub = rospy.Publisher("filtered_scan", LaserScan, queue_size=10)` declares that your node is publishing to the *filtered_scan* topic using the message type `LaserScan`. This lets the master tell any nodes listening on *filtered_scan* that we are going to publish data on that topic. ```python angles = linspace(msg.angle_min, msg.angle_max, len(msg.ranges)) @@ -171,7 +171,7 @@ Substitute in the new ranges in the original message, and republish it. rospy.init_node('scan_filter') ScanFilter() ``` -The next line, `rospy.init_node(NAME, ...)`, is very important as it tells rospy the name of your node -- until rospy has this information, it cannot start communicating with the ROS Master. In this case, your node will take on the name talker. NOTE: the name must be a base name, i.e. it cannot contain any slashes "/". +The next line, `rospy.init_node(NAME, ...)`, is very important as it tells rospy the name of your node -- until rospy has this information, it cannot start communicating with the ROS Master. **NOTE:** the name must be a base name, i.e. it cannot contain any slashes "/". Instantiate the class with `ScanFilter()` diff --git a/src/move.py b/src/move.py index 5691193..e5f42af 100755 --- a/src/move.py +++ b/src/move.py @@ -8,12 +8,12 @@ from geometry_msgs.msg import Twist class Move: """ - A class that sends Twist messages to move the Stretch robot foward. + A class that sends Twist messages to move the Stretch robot forward. """ def __init__(self): """ Function that initializes the publisher. - :param self: The self reference + :param self: The self reference. """ # Setup a publisher that will send the velocity commands to Stretch # This will publish on a topic called "/stretch/cmd_vel" with a message type Twist diff --git a/src/scan_filter.py b/src/scan_filter.py index b5ee192..e66d791 100755 --- a/src/scan_filter.py +++ b/src/scan_filter.py @@ -10,7 +10,7 @@ from sensor_msgs.msg import LaserScan class ScanFilter: """ A class that implements a LaserScan filter that removes all of the points. - that are not infront of the robot. + that are not in front of the robot. """ def __init__(self): # We're going to assume that the robot is pointing up the x-axis, so that @@ -33,11 +33,11 @@ class ScanFilter: def callback(self,msg): """ - Callback function to deal with incoming laserscan messages. + Callback function to deal with incoming LaserScan messages. :param self: The self reference. - :param msg: The subscribed laserscan message. + :param msg: The subscribed LaserScan message. - :publishes msg: updated laserscan message. + :publishes msg: updated LaserScan message. """ # Figure out the angles of the scan. We're going to do this each time, # in case we're subscribing to more than one laser, with different numbers of beams