RSE2107A Systems Engineering Project


Python API

    Table of Contents
  1. Node initialisation
  2. Publishing
  3. Subscribing
  4. Service
  5. Time & Delays
  6. Loops
  7. Extras
  8. Exceptions
  1. Node initialisation
  2. At the beginning of your code, the first thing to be done is to initialize the node. This runs the necessary constructors required for the node to work.

    rospy.init_node( <node_name>, <anonymous>, <log_level>, <disable_signals> )

  3. Publishing
  4. rospy.Publisher( <topic_name>, <msg_type>, <subscriber_listener>, <tcp_nodelay>, <latch>, <headers>, <queue_size> )

    rospy.Publisher.publish( <msg_member_type> )
  5. Subscribing
  6. rospy.Subscriber( <topic_name>, <msg_type>, <callback> )

  7. Service
  8. rospy.Service( <service_name>, <service_class>, <handler>, <buffer_size> )

    rospy.ServiceProxy( <service_name>, <service_class>, <persistent>, <headers> )

    rospy.wait_for_service( <service_name>, <timeout> )

  9. Time & Delays
  10. rospy.Time( <secs>, <nsecs> )

    rospy.Time.now( <empty> )

    rospy.Time.from_sec( <float_secs> )

    rospy.get_time( <empty> )

    rospy.Duration( <secs> )

    rospy.Duration.from_sec( <float_secs> )

    rospy.sleep( <duration> )

  11. Loops
  12. rospy.Rate( <hz> )

    rospy.Timer( <period>, <callback>, <oneshot> )

  13. Extras
  14. rospy.spin( <empty> )

  15. Exceptions
  16. ROSException
    Base exception class for ROS clients.
    ROSSerializationException
    Exception for message serialization errors.
    ROSInitException
    Exception for errors initializing ROS state.
    ROSInterruptException
    Exception for operations that interrupted. This is most commonly used with rospy.sleep() and rospy.Rate.
    ROSInternalException
    Base class for exceptions that occur due to internal rospy errors (i.e. bugs).
    ServiceException
    Errors related to communicate with ROS Services.

By: Muhammad Syamim Bin Shamsulbani