root / scout / libscout / src / libscout.cpp @ 4589a2a9
History | View | Annotate | Download (3.19 KB)
1 | c406f16b | Ben | /**
|
---|---|---|---|
2 | 0121ead7 | bwasserm | * Copyright (c) 2011 Colony Project
|
3 | c406f16b | Ben | *
|
4 | * Permission is hereby granted, free of charge, to any person
|
||
5 | * obtaining a copy of this software and associated documentation
|
||
6 | * files (the "Software"), to deal in the Software without
|
||
7 | * restriction, including without limitation the rights to use,
|
||
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
9 | * copies of the Software, and to permit persons to whom the
|
||
10 | * Software is furnished to do so, subject to the following
|
||
11 | * conditions:
|
||
12 | *
|
||
13 | * The above copyright notice and this permission notice shall be
|
||
14 | * included in all copies or substantial portions of the Software.
|
||
15 | *
|
||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||
23 | * OTHER DEALINGS IN THE SOFTWARE.
|
||
24 | **/
|
||
25 | |||
26 | |||
27 | /**
|
||
28 | * @file libscout.cpp
|
||
29 | * @brief Contains top level scout library functions
|
||
30 | *
|
||
31 | * Contains functions and definitions for the use of
|
||
32 | * libscout
|
||
33 | *
|
||
34 | * @author Colony Project, CMU Robotics Club
|
||
35 | **/
|
||
36 | |||
37 | /* Author: Ben Wasserman
|
||
38 | */
|
||
39 | |||
40 | #include "libscout.h" |
||
41 | |||
42 | 0121ead7 | bwasserm | /* Global objects */
|
43 | ros::NodeHandle libscout_node; |
||
44 | |||
45 | c406f16b | Ben | /** \todo Decide how to call user behaviors
|
46 | * I'm thinking that there be a function call in main that calls the "main"
|
||
47 | fn in the user behavior. However, their "main" function will not be called
|
||
48 | main. However, this has to be able to point to different functions by
|
||
49 | changing as little code in this file as possible. Also, the user behaviors
|
||
50 | should live in a different directory (possibly a different package).
|
||
51 | However, this other package should not be executed as a separate node,
|
||
52 | because that is the job of the libscout node/package to handle all the ROS
|
||
53 | stuff, and keep it under the lid. The user only has to call normal c
|
||
54 | functions. I also want to reduce the need to recompile this package when the
|
||
55 | user behavior, or any other package that works below the surface.
|
||
56 | **/
|
||
57 | |||
58 | 0121ead7 | bwasserm | /*!
|
59 | * \brief LibScout. Primary library for interfacing behaviors with scout hw.
|
||
60 | *
|
||
61 | * This is the main function for libscout. It is run when the node starts and
|
||
62 | * starts the library. It calls init() which initializes the clients and
|
||
63 | * publishers/subscribers for the other parts of the library.
|
||
64 | *
|
||
65 | * \param argc The number of command line arguments (should be 1)
|
||
66 | * \param argv The array of command line arguments
|
||
67 | **/
|
||
68 | c406f16b | Ben | int main(int argc, char **argv){ |
69 | ros::init(argc, argv, "libscout");
|
||
70 | |||
71 | init(LIB_ALL); |
||
72 | /** \todo remove this test code **/
|
||
73 | 0121ead7 | bwasserm | // motors_set(100, MOTOR_ALL);
|
74 | ROS_INFO("%d", motors_query(MOTOR_FL));
|
||
75 | c406f16b | Ben | |
76 | return 0; |
||
77 | } |
||
78 | |||
79 | 0121ead7 | bwasserm | /*!
|
80 | * \brief Initializes modules in the libscout.
|
||
81 | *
|
||
82 | * Calls init functions for each module in libscout.
|
||
83 | * \param modules A bitmask of the modules that will be initialized.
|
||
84 | **/
|
||
85 | c406f16b | Ben | int init(int modules){ |
86 | 0121ead7 | bwasserm | /** \todo Copy this if for each module that gets added to the library */
|
87 | c406f16b | Ben | if(modules & LIB_MOTORS){
|
88 | libmotors_init(); |
||
89 | } |
||
90 | /** \todo Add other lib inits **/
|
||
91 | return 0; |
||
92 | } |