From efc1bc32fa4b04b3e79cd0aeec4452a2f9fe82e3 Mon Sep 17 00:00:00 2001 From: "Alan G. Sanchez" Date: Mon, 29 Aug 2022 11:14:37 -0700 Subject: [PATCH] Fixed typos. --- example_5.md | 19 +++++++------------ src/joint_state_printer.py | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/example_5.md b/example_5.md index 4a3e7b8..495cba7 100644 --- a/example_5.md +++ b/example_5.md @@ -10,7 +10,6 @@ Begin by starting up the stretch driver launch file. # Terminal 1 roslaunch stretch_core stretch_driver.launch ``` - You can then hit the run-stop button (you should hear a beep and the LED light in the button blink) and move the robot's joints to a desired configuration. Once you are satisfied with the configuration, hold the run-stop button until you hear a beep. Then run the following command to print the joint positions of the lift, arm, and wrist. ```bash @@ -23,7 +22,6 @@ name: ['joint_lift', 'wrist_extension', 'joint_wrist_yaw'] position: [0.6043133175850597, 0.19873586673129257, 0.017257283863713464] ``` - **IMPORTANT NOTE:** Stretch's arm has 4 prismatic joints and the sum of these positions gives the *wrist_extension* distance. The *wrist_extension* is needed when sending [joint trajectory commands](follow_joint_trajectory.md) to the robot. Further, you **can not** actuate an individual arm joint. Here is an image of the arm joints for reference:

@@ -44,7 +42,7 @@ class JointStatePublisher(): """ def __init__(self): """ - Function that initializes the subsriber. + Function that initializes the subscriber. :param self: The self reference. """ self.sub = rospy.Subscriber('joint_states', JointState, self.callback) @@ -61,7 +59,7 @@ class JointStatePublisher(): """ print_states function to deal with the incoming JointState messages. :param self: The self reference. - :param joints: A list of joint names. + :param joints: A list of string values of joint names. """ joint_positions = [] for joint in joints: @@ -95,13 +93,12 @@ Now let's break the code down. ``` Every Python ROS [Node](http://wiki.ros.org/Nodes) will have this declaration at the top. The first line makes sure your script is executed as a Python script. - ```python import rospy import sys from sensor_msgs.msg import JointState ``` -You need to import rospy if you are writing a ROS Node. Import `sensor_msgs.msg` so that we can subscribe to `JointState` messages. +You need to import `rospy` if you are writing a ROS [Node](http://wiki.ros.org/Nodes). Import `sensor_msgs.msg` so that we can subscribe to `JointState` messages. ```python self.sub = rospy.Subscriber('joint_states', JointState, self.callback) @@ -112,12 +109,11 @@ Set up a subscriber. We're going to subscribe to the topic "*joint_states*", lo def callback(self, msg): self.joint_states = msg ``` -This is the callback function where he JointState messages are stored as *self.joint_states*. Further information about the this message type can be found here: [JointState Message](http://docs.ros.org/en/lunar/api/sensor_msgs/html/msg/JointState.html) +This is the callback function where he `JointState` messages are stored as *self.joint_states*. Further information about the this message type can be found here: [JointState Message](http://docs.ros.org/en/lunar/api/sensor_msgs/html/msg/JointState.html) ```python def print_states(self, joints): joint_positions = [] - ``` This is the `print_states()` function which takes in a list of joints of interest as its argument. the is also an empty list set as *joint_positions* and this is where the positions of the requested joints will be appended. @@ -136,7 +132,6 @@ In this section of the code, a for loop is used to parse the names of the reques rospy.signal_shutdown("done") sys.exit(0) ``` - The first line of code initiates a clean shutdown of ROS. The second line of code exits the Python interpreter. ```python @@ -144,18 +139,18 @@ rospy.init_node('joint_state_printer', anonymous=True) JSP = JointStatePublisher() rospy.sleep(.1) ``` -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 "/". Declare object, *JSP*, from the `JointStatePublisher` class. -The use of the `rospy.sleep()` function is to allow the *JSP* class to initialize all of its features before requesting to publish joint positions of desired joints (running the `print_states()` function). +The use of the `rospy.sleep()` function is to allow the *JSP* class to initialize all of its features before requesting to publish joint positions of desired joints (running the `print_states()` method). ```python joints = ["joint_lift", "wrist_extension", "joint_wrist_yaw"] #joints = ["joint_head_pan","joint_head_tilt", joint_gripper_finger_left", "joint_gripper_finger_right"] JSP.print_states(joints) ``` -Create a list of the desired joints that you want positions to be printed. Then use that list as an argument for the `print_states()` function. +Create a list of the desired joints that you want positions to be printed. Then use that list as an argument for the `print_states()` method. ```python rospy.spin() diff --git a/src/joint_state_printer.py b/src/joint_state_printer.py index a37535b..360811e 100755 --- a/src/joint_state_printer.py +++ b/src/joint_state_printer.py @@ -15,7 +15,7 @@ class JointStatePublisher(): def __init__(self): """ - Function that initializes the subsriber. + Function that initializes the subscriber. :param self: The self reference """ # Set up a subscriber. We're going to subscribe to the topic "joint_states" @@ -36,7 +36,7 @@ class JointStatePublisher(): """ print_states function to deal with the incoming JointState messages. :param self: The self reference. - :param joints: A list of joint names. + :param joints: A list of string values of joint names. """ # Create an empty list that will store the positions of the requested joints joint_positions = []