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/MotorControl.cpp
37 37

  
38 38
#include "MotorControl.h"
39 39

  
40
using namespace std;
41

  
40 42
/**
41 43
 * @brief Initialize the motors module of libscout.
42 44
 *
43 45
 * Initialize the libscout node as a publisher of set_motors and a client of
44 46
 * query_motors.
45 47
 */
46
MotorControl::MotorControl(const ros::NodeHandle& libscout_node)
48
MotorControl::MotorControl(const ros::NodeHandle& libscout_node,
49
                           string scoutname)
47 50
    : node(libscout_node)
48 51
{
49 52
    set_motors_pub =
50
        node.advertise<motors::set_motors>("scout1/set_motors", QUEUE_SIZE);
53
        node.advertise<motors::set_motors>(scoutname + "/set_motors",
54
                                           QUEUE_SIZE);
51 55
    query_motors_client =
52
        node.serviceClient<motors::query_motors>("query_motors");
56
        node.serviceClient<motors::query_motors>(scoutname + "/query_motors");
53 57
}
54 58

  
55 59
/**

Also available in: Unified diff