Project

General

Profile

Revision 5d0687a9

ID5d0687a9991d806c94fc7c21405334e6717e3611

Added by Priya about 7 years ago

Small changes to wireless, and starting turning with line following.

View differences:

scout/libscout/src/WirelessReceiver.cpp
42 42
/**
43 43
 * @brief Initializes wireless receiver
44 44
 * 
45
 * @param libscout_node Node handle of the ROS node used by libscout.
46
 **/
47
WirelessReceiver::WirelessReceiver(const ros::NodeHandle& libscout_node)
48
    : node(libscout_node)
49
{
50
    sub = node.subscribe("/wireless/receive", QUEUE_SIZE,
51
          &WirelessReceiver::receive, this);
52
}
53

  
54
/**
55
 * @brief Registers a function to be called upon receipt of a packet.
56
 *
45 57
 * @param callback A function pointer to a function which is called whenever a
46 58
 * wireless packet is received. It should be of form:
47 59
 *     void callback(const WirelessPacketConstPtr& packet);
48 60
 **/
49
WirelessReceiver::WirelessReceiver(WirelessCallback callback)
50
    : callback(callback)
61
void WirelessReceiver::register_callback(WirelessCallback new_callback)
51 62
{
52
    sub = nh.subscribe("/wireless/receive", QUEUE_SIZE,
53
        &WirelessReceiver::receive, this);
63
    callback = new_callback;
54 64
}
55 65

  
56 66
/**
......
60 70
 **/
61 71
void WirelessReceiver::receive(const ::messages::WirelessPacketConstPtr& packet)
62 72
{
63
    (*callback)(packet);
73
    if (callback == NULL)
74
    {
75
        ROS_WARN("Warning: Ignored wireless packet.");
76
    }
77
    else
78
    {
79
        (*callback)(packet->data);
80
    }
64 81
}

Also available in: Unified diff