Project

General

Profile

Revision 5d0687a9

ID5d0687a9991d806c94fc7c21405334e6717e3611

Added by Priya over 7 years ago

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

View differences:

scout/libscout/src/WirelessSender.cpp
40 40
using namespace std;
41 41
using namespace ::messages;
42 42

  
43
WirelessSender::WirelessSender(uint16_t type, uint16_t dest, uint16_t pan,
44
    uint16_t channel)
43
WirelessSender::WirelessSender(const ros::NodeHandle& libscout_node,
44
                               uint16_t type, uint16_t pan, uint16_t channel)
45
    : node(libscout_node)
45 46
{
46 47
    packet.type = type;
47
    packet.dest = dest;
48 48
    packet.pan = pan;
49 49
    packet.channel = channel;
50
    pub = nh.advertise< ::messages::WirelessPacket>("/wireless/send",
51
        QUEUE_SIZE);
50
    pub = node.advertise< ::messages::WirelessPacket>("/wireless/send",
51
                                                      QUEUE_SIZE);
52 52
}
53 53

  
54 54
void WirelessSender::setType(uint16_t type)
55 55
{
56 56
    packet.type = type;
57 57
}
58
void WirelessSender::setDest(uint16_t dest)
59
{
60
    packet.dest = dest;
61
}
62 58
void WirelessSender::setPan(uint16_t pan)
63 59
{
64 60
    packet.pan = pan;
......
68 64
    packet.channel = channel;
69 65
}
70 66

  
71
void WirelessSender::send(uint8_t data[], int length)
67
void WirelessSender::send(uint8_t data[], int length, uint16_t dest)
72 68
{
69
    packet.dest = dest;
73 70
    packet.data.clear();
74 71
    for (int i = 0; i < length; i++)
75 72
    {
76 73
        packet.data.push_back(data[i]);
77 74
    }
78
    publish();
75
    pub.publish(packet);
79 76
}
80 77

  
81
void WirelessSender::send(vector<uint8_t>& data)
78
void WirelessSender::send(vector<uint8_t>& data, uint16_t dest)
82 79
{
80
    packet.dest = dest;
83 81
    packet.data = data;
84
    publish();
85
}
86

  
87
void WirelessSender::publish()
88
{
89 82
    pub.publish(packet);
90 83
}

Also available in: Unified diff