From 8c9e1297c554010f1126ab530d3264c1a349a017 Mon Sep 17 00:00:00 2001 From: hello-sanchez Date: Thu, 18 Aug 2022 13:54:57 -0700 Subject: [PATCH] Included argument. --- example_6.md | 7 ++++--- src/effort_sensing.py | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/example_6.md b/example_6.md index a4aab27..39fef10 100644 --- a/example_6.md +++ b/example_6.md @@ -44,17 +44,18 @@ class JointActuatorEffortSensor(hm.HelloNode): """ A class that sends multiple joint trajectory goals to a single joint. """ - def __init__(self): + def __init__(self, export_data=False): """ Function that initializes the subscriber,and other features. :param self: The self reference. + :param export_data: A boolean message type. """ hm.HelloNode.__init__(self) self.sub = rospy.Subscriber('joint_states', JointState, self.callback) self.joints = ['joint_lift'] self.joint_effort = [] self.save_path = '/home/hello-robot/catkin_ws/src/stretch_tutorials/stored_data' - self.export_data = False + self.export_data = export_data def callback(self, msg): """ @@ -140,7 +141,7 @@ class JointActuatorEffortSensor(hm.HelloNode): if __name__ == '__main__': try: - node = JointActuatorEffortSensor() + node = JointActuatorEffortSensor(export_data=True) node.main() except KeyboardInterrupt: rospy.loginfo('interrupt received, so shutting down') diff --git a/src/effort_sensing.py b/src/effort_sensing.py index 5ddf351..1b89cf5 100755 --- a/src/effort_sensing.py +++ b/src/effort_sensing.py @@ -29,12 +29,13 @@ class JointActuatorEffortSensor(hm.HelloNode): """ A class that sends multiple joint trajectory goals to a single joint. """ - # Initialize the inhereted hm.Hellonode class. - def __init__(self): + def __init__(self, export_data=False): """ Function that initializes the subscriber,and other features. :param self: The self reference. + :param export_data: A boolean message type. """ + # Initialize the inhereted hm.Hellonode class. hm.HelloNode.__init__(self) # Set up a subscriber. We're going to subscribe to the topic "joint_states" @@ -50,7 +51,7 @@ class JointActuatorEffortSensor(hm.HelloNode): self.save_path = '/home/hello-robot/catkin_ws/src/stretch_tutorials/stored_data' # Create boolean data type for conditional statements if you want to export effort data. - self.export_data = False + self.export_data = export_data def callback(self, msg): @@ -89,7 +90,7 @@ class JointActuatorEffortSensor(hm.HelloNode): # Make the action call and send the goal. Also define the feedback and # done callback function. self.trajectory_client.send_goal(trajectory_goal, feedback_cb=self.feedback_callback, done_cb=self.done_callback) - rospy.loginfo('Sent stow goal = {0}'.format(trajectory_goal)) + rospy.loginfo('Sent position goal = {0}'.format(trajectory_goal)) self.trajectory_client.wait_for_result() @@ -173,7 +174,7 @@ class JointActuatorEffortSensor(hm.HelloNode): if __name__ == '__main__': try: # Declare object, node, from JointActuatorEffortSensor class - node = JointActuatorEffortSensor() + node = JointActuatorEffortSensor(export_data=True) node.main() except KeyboardInterrupt: rospy.loginfo('interrupt received, so shutting down')