Revision a2b7e8f1

View differences:

scout/libscout/src/Behavior.cpp
54 54
    name = my_name;
55 55
    sensors->init(&motors, &buttons, &sonar, &encoders, &linesensor,
56 56
                        &wl_sender, &wl_receiver);
57
    wl_receiver->register_callback(std::bind(&Behavior::default_callback,
58
        this, std::placeholders::_1));
59

  
57 60
    loop_rate = new ros::Rate(10);
58 61
}
59 62

  
60 63
/**
64
 * Cleans up after a behavior is killed.
65
 */
66
Behavior::~Behavior()
67
{
68
  motors->set_sides(0, 0, MOTOR_ABSOLUTE);
69
  delete wl_receiver;
70
  delete loop_rate;
71
}
72

  
73
/**
74
 * Empty callback used as default callback for wireless receiver.
75
 */
76
void Behavior::default_callback(vector<uint8_t> data)
77
{
78
  return;
79
}
80

  
81
/**
61 82
 * Allows the behavior to check ros::ok(), without being aware of ROS.
62 83
 */
63 84
bool Behavior::ok()
scout/libscout/src/Behavior.h
63 63
        Behavior(std::string scoutname, std::string name,
64 64
                 Sensors * sensor);
65 65

  
66
        virtual ~Behavior();
67

  
66 68
        /// Extended by subclasses to actually run the behavior.
67 69
        virtual void run() = 0;
68 70

  
......
85 87
        WirelessSender * wl_sender;
86 88
        WirelessReceiver * wl_receiver;
87 89

  
90
        // Default callback for wireless receiver.
91
        void default_callback(std::vector<uint8_t> data);
92

  
88 93
        // Wrappers for ROS functions
89 94
        bool ok();
90 95
        void spin();

Also available in: Unified diff