title: How to Automate terminal commands of ROS using a python script
body: <p>I am currently trying to write an executable program in python that runs the following ROS command: <code>rostopic echo dvrk/PSM1/position_cartesian_current</code> however despite reading the ROS Tutorials, I am unsure how to go about doing this. Within a file called <code>arm.py</code> the following subscriber and definition already exist:</p>
  
  <pre><code>rospy.Subscriber(self.__full_ros_namespace + '/position_cartesian_current', PoseStamped, self.__position_cartesian_current_cb)
  
  def __position_cartesian_current_cb(self, data):
          self.__position_cartesian_current = posemath.fromMsg(data.pose)
  </code></pre>
  
  <p>Am I supposed to reuse this subscriber and definition in the new automated python script? After obtaining the current Cartesian position, the robot will subsequently be moved to a different position, which can currently be accomplished using ROS commands in the terminal, however, the aim is to write a python script that automates these commands. Any help would be greatly appreciated!</p>
  
  <pre><code>import rospy
  from tf import transformations
  from tf_conversions import posemath
  from std_msgs.msg import String, Bool, Float32, Empty, Float64MultiArray
  from geometry_msgs.msg import Pose, PoseStamped, Vector3, Quaternion, Wrench, WrenchStamped, TwistStamped
  
  def callback(data):
    rospy.loginfo(rospy.get_caller_id() + data.data)
  
  def listener():
      rospy.init_node('listener', anonymous=True)
      rospy.Subscriber(self.__full_ros_namespace + '/position_cartesian_current', PoseStamped, callback)
      rospy.spin()
  
  if __name__ == '__main__':
      listener()
  </code></pre>