Project

General

Profile

Revision c384dc7e

IDc384dc7e5c99254e07ef0d46bef2b9dfaf32e817

Added by Alex Zirbel over 12 years ago

Updated the Behavior definition and extensions.

The Behavior.cpp/h class now works and can be extended by simply implementing its run() method. However, the subclass must also be extantiated and used in an external executable. An example of this can be seen in PriyaBehavior.cpp/h, and the executable, priya_behavior_process.cpp. In the future, we should move all behaviors into a behaviors/ folder, and autogenerate the executable to be compiled.

I also changed Behavior and the MotorControl class to accept a scoutname string as a parameter so that each behavior only controls a single scout. This means when you call the priya_behavior_process executable, you pass it one argument (the name of the scout in scoutsim), and all control classes will prefix their output ROS messages with that scoutname so that only the scout you intended gets the messages.

I removed behavior files which do not use this new abstract behavior class.

View differences:

scout/libscout/src/Behavior.cpp
31 31
 *
32 32
 * @author Colony Project, CMU Robotics Club
33 33
 * @author Priyanka Deo
34
 * @author Alex Zirbel
34 35
 **/
35 36

  
36 37
#include "Behavior.h"
37 38

  
38
Behavior::init(int argc, char** argv)
39
{
40
    ros::init(argc, argv, "libscout");
39
using namespace std;
41 40

  
42
    motors(node);
41
Behavior::Behavior(string scoutname)
42
{
43
    motors = new MotorControl(node, scoutname);
44
    loop_rate = new ros::Rate(10);
43 45
    //buttons(node);
44 46
    //sonar(node);
45

  
46
    ros::Rate loop_rate(10);
47 47
}
48 48

  
49
Behavior::ok()
49
bool Behavior::ok()
50 50
{
51
    return ros::ok()
51
    return ros::ok();
52 52
}
53 53

  
54
Behavior::spin()
54
void Behavior::spin()
55 55
{
56 56
    ros::spin();
57 57
    return;
58 58
}
59 59

  
60
Behavior::spinOnce()
60
void Behavior::spinOnce()
61 61
{
62
    ros::SpinOnce();
62
    ros::spinOnce();
63 63
    return;
64 64
}

Also available in: Unified diff