Project

General

Profile

Revision a8480867

IDa84808670408804bf5ce08741a3b59130351928f

Added by Alex Zirbel over 12 years ago

Made a lot of changes to the general structure.

Applied object-orienting techniques to the code, cleaning it up considerably. Major design changes are as follows:

  • All separate node code (ie motors) are meant to only interface with hardware - doing as little logic as possible.
  • Instead, the logic is moved to a class (ie MotorControl) in libscout. PID and other tools should be located here. This significantly reduces dependencies.
  • Files can be included cross-package by being placed in /include/packagename, but this should be avoided to reduce dependencies.

A few formatting changes:

  • Comments should end with / always, not */
  • Use @ instead of \
  • No double newlines.

The motors node is revamped and pretty much correct at this point.

View differences:

scout/libscout/src/libscout.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
24
 */
26 25

  
27 26
/**
28 27
 * @file libscout.cpp
......
33 32
 *
34 33
 * @author Colony Project, CMU Robotics Club
35 34
 * @author Ben Wasserman
36
 **/
35
 */
37 36

  
38 37
#include "libscout.h"
39 38

  
40
/* Global objects */
41
ros::NodeHandle node;
42

  
43
/** \todo Decide how to call user behaviors
44
  * I'm thinking that there be a function call in main that calls the "main"
45
  fn in the user behavior. However, their "main" function will not be called 
46
  main. However, this has to be able to point to different functions by 
47
  changing as little code in this file as possible. Also, the user behaviors
48
  should live in a different directory (possibly a different package).
49
  However, this other package should not be executed as a separate node,
50
  because that is the job of the libscout node/package to handle all the ROS 
51
  stuff, and keep it under the lid. The user only has to call normal c 
52
  functions. I also want to reduce the need to recompile this package when the 
53
  user behavior, or any other package that works below the surface.
54
**/
39
/** @todo Decide how to call user behaviors
40
 *
41
 * I'm thinking that there be a function call in main that calls the "main"
42
 fn in the user behavior. However, their "main" function will not be called 
43
 main. However, this has to be able to point to different functions by 
44
 changing as little code in this file as possible. Also, the user behaviors
45
 should live in a different directory (possibly a different package).
46
 However, this other package should not be executed as a separate node,
47
 because that is the job of the libscout node/package to handle all the ROS 
48
 stuff, and keep it under the lid. The user only has to call normal c 
49
 functions. I also want to reduce the need to recompile this package when the 
50
 user behavior, or any other package that works below the surface.
51
 */
55 52

  
56
/*!
57
 * \brief Initializes modules in the libscout.
53
/**
54
 * @brief Initializes modules in the libscout.
58 55
 * 
59 56
 * Calls init functions for each module in libscout.
60
 * \param modules A bitmask of the modules that will be initialized.
61
 **/
62
int init(int modules, int argc, char **argv){
63
	ros::init(argc, argv, "libscout");
57
 * @param modules A bitmask of the modules that will be initialized.
58
 */
59
int init(int modules, int argc, char **argv)
60
{
61
    ros::init(argc, argv, "libscout");
62

  
63
    ros::NodeHandle node;
64

  
65
    MotorControl motors = new MotorControl(node);
66
    HeadLightControl headlights = new HeadlightControl(node);
64 67

  
65
  /** \todo Copy this if for each module that gets added to the library */
66
  if(modules & LIB_MOTORS){
67
    libmotors_init();
68
  }
69
	if(modules & LIB_HEADLIGHTS){
70
    libheadlights_init();
71
  }
72
  if(modules & LIB_BUTTONS){
73
    libbuttons_init();
74
  }
75
  /** \todo Add other lib inits **/
76
  return 0;
68
    /** @todo Copy this if for each module that gets added to the library */
69
    /*if(modules & LIB_MOTORS)
70
    {
71
        libmotors_init();
72
    }
73
    if(modules & LIB_HEADLIGHTS)
74
    {
75
        libheadlights_init();
76
    }
77
    if(modules & LIB_BUTTONS)
78
    {
79
        libbuttons_init();
80
    }*/
81
    /** @todo Add other lib inits **/
82
    return 0;
77 83
}
78 84

  

Also available in: Unified diff