Project

General

Profile

Revision b00761a0

IDb00761a0e88f934a309a939b653d9f441b127ae8
Parent c492be62
Child 4069a378

Added by Alex Zirbel over 12 years ago

Updated ButtonControl and SonarControl.

Finally, the behavior compiles. Had to fix a lot of problems involving misunderstandings with Publisher/Client/ServiceServer/ServiceClient confusion.

We can now run priya_behavior as an executable, though the process for generating behavior executables still needs some work.

View differences:

scout/libscout/src/ButtonControl.cpp
34 34
 * @author Colony Project, CMU Robotics Club
35 35
 * @author Priyanka Deo
36 36
 * @author Leon Zhang
37
 * @author Alex Zirbel
37 38
 **/
38 39

  
39 40
#include "ButtonControl.h"
40 41

  
41
/*!
42
using namespace std;
43

  
44
/**
42 45
 * @brief Initialize the buttons module of libscout.
43 46
 *
44 47
 * Initialize the libscout node as a subscriber of button_event
45 48
 */
46
ButtonControl::ButtonControl(const ros::NodeHandle& libscout_node) : node(libscout_node)
49
ButtonControl::ButtonControl(const ros::NodeHandle& libscout_node,
50
                             string scoutname)
51
    : node(libscout_node)
47 52
{
48
    button_event_sub = node.subscribe("button_event", QUEUE_SIZE, event_button);
53
    button_event_sub = node.subscribe(scoutname + "/button_event",
54
                                      QUEUE_SIZE,
55
                                      &ButtonControl::event_callback,
56
                                      this);
49 57
}
50 58

  
51
/*!*
59
/**
52 60
 * @brief Respond to button events
53
 * Sends out button events if buttons are pressed. 
54 61
 * Processes message and updates private variables
55
 * 
56
 * @param subscription to button_event message
57 62
 */
58
void ButtonControl::event_button(const buttons::button_event::ConstPtr& msg)
63
void ButtonControl::event_callback(const buttons::button_event::ConstPtr& msg)
59 64
{
60
    button1_pressed = msg.button1_pressed;
61
    button2_pressed = msg.button2_pressed;
65
    button1_value = msg->button1_pressed;
66
    button2_value = msg->button2_pressed;
62 67
}
63 68

  
64 69
/**
65
*@brief check if button 1 is currently being pressed
66
* 
67
*@return true if button is pressed, otherwise false
68
*/
70
 * @brief check if button 1 is currently being pressed
71
 * 
72
 * @return true if button is pressed, otherwise false
73
 */
69 74
bool ButtonControl::button1_is_pressed()
70 75
{
71 76
    return button1_value;
72 77
}
73 78

  
74 79
/**
75
*@brief check if button 2 is currently being pressed
76
* 
77
*@return true if button is pressed, otherwise false
78
*/
80
 * @brief check if button 2 is currently being pressed
81
 * 
82
 * @return true if button is pressed, otherwise false
83
 */
79 84
bool ButtonControl::button2_is_pressed()
80 85
{ 
81 86
    return button2_value;

Also available in: Unified diff