ROS Serial C client library
rosNodeHandle Struct Reference

Structure to hold information about a nodehandle. More...

#include <ros_types.h>

Collaboration diagram for rosNodeHandle:

Data Fields

rosPublisher_t *(* advertise )(rosMessageHandle_t *messagehandle, char *topic, uint16_t buffer_size)
 Advertises a topic to nodehandle.
rosSubscriber_t *(* subscribe )(rosMessageHandle_t *messagehandle, char *topic, uint16_t buffer_size, void(*callback)(void *message))
 Subscribes a topic to a nodehandle.
struct rosSpinnerspinner
rosInterface_tinterface
rosPublisher_tpublishers [MAX_PUBLISHERS]
rosSubscriber_tsubscribers [MAX_SUBSCRIBERS]
uint8_t publisher_count
uint8_t subscriber_count
rosReturnCode_t ok
rosReturnCode_t configured

Detailed Description

Structure to hold information about a nodehandle.


Field Documentation

rosPublisher_t*(* advertise)(rosMessageHandle_t *messagehandle, char *topic, uint16_t buffer_size)

Advertises a topic to nodehandle.

Parameters:
mhPointer to messagehandle
topicTopic name
buffer_sizeBuffer size
Returns:
Pointer to created publisher

Example Usage:

    // init ROS
    rosInit(NULL);
    // get pointer to a nodehandle
    rosNodeHandle_t* nh = rosNodeHandle("my_nodehandle_interface_id");
    // create message
    MyMessage_t my_message = rosCreateMyMessage_t(nh);
    // advertise message
    rosPublisher_t* my_message_pub = nh->advertise(&my_message.mh, "MyMessage", 512);
    // publish message
    my_message_pub->publish(&my_message);

indicates if topics are already negotiated

device interface

indicates if nodehandle is still alive

uint8_t publisher_count

number of publishers

rosPublisher_t* publishers[MAX_PUBLISHERS]

array of publishers

nodehandle spinner

rosSubscriber_t*(* subscribe)(rosMessageHandle_t *messagehandle, char *topic, uint16_t buffer_size, void(*callback)(void *message))

Subscribes a topic to a nodehandle.

Parameters:
mhPointer to messagehandle
topicTopic name
buffer_sizeBuffer size
Returns:
Pointer to created subscriber

Example Usage:

Subscribers callback function:

    void myMessageCallback(void *message)
    {
      // cast message
      MyMessage_t *my_message = message;
      // Do something here.
    }

Program code:

    // init ROS
    rosInit(NULL);
    // get pointer to a nodehandle
    rosNodeHandle_t* nh = rosNodeHandle("my_nodehandle_interface_id");
    // create message
    MyMessage_t my_message = rosCreateMyMessage_t(nh);
    // advertise message
    rosSubscriber_t* my_message_sub = nh->subscribe(&my_message.mh, "MyMessage", 512, myMessageCallback);
    // spin ROS continously to process callbacks
    rosSpin();

number of subscribers

rosSubscriber_t* subscribers[MAX_SUBSCRIBERS]

array of subscribers


The documentation for this struct was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines