Revision bb64f5e5

View differences:

scout/libscout/CMakeLists.txt
35 35
set(MAIN_FILES src/Sensors.cpp src/Behavior.cpp src/BehaviorList.cpp src/BehaviorProcess.cpp)
36 36
FILE(GLOB BEHAVIOR_FILES "${PROJECT_SOURCE_DIR}/src/behaviors/*.cpp")
37 37
FILE(GLOB TEST_BEHAVIOR_FILES "${PROJECT_SOURCE_DIR}/src/test_behaviors/*.cpp")
38
FILE(GLOB HELPER_FILES "${PROJECT_SOURCE_DIR}/src/helper_classes/*.cpp")
38 39

  
39
set(HELPER_FILES src/helper_classes/Order.cpp src/helper_classes/PQWrapper.cpp)
40 40
set(CONTROL_CLASSES src/MotorControl.cpp src/SonarControl.cpp src/HeadlightControl.cpp src/ButtonControl.cpp src/WirelessSender.cpp src/WirelessReceiver.cpp src/EncodersControl.cpp src/LinesensorControl.cpp)
41 41

  
42 42
rosbuild_add_executable(libscout ${MAIN_FILES} ${BEHAVIOR_FILES} ${TEST_BEHAVIOR_FILES} ${CONTROL_CLASSES} ${HELPER_FILES})
scout/libscout/src/behaviors/Odometry.h
4 4
#include "../Behavior.h"
5 5
#include "../Sensors.h"
6 6
#include "messages/ScoutPosition.h"
7

  
7
#include "../helper_classes/ScoutPosition.h"
8 8

  
9 9
#define WHEEL_RADIUS  .2
10 10
#define WHEEL_CIRCUM  (2*M_PI*WHEEL_RADIUS)
......
12 12
#define ENCODER_COUNT (2*WHEEL_RADIUS*350*M_PI/WHEEL_BASE)
13 13
#define DIST_PER_TICK (WHEEL_CIRCUM/ENCODER_COUNT)
14 14

  
15
typedef struct{
16
  float x;
17
  float y;
18
  float theta;
19
} pos;
20

  
21 15
class Odometry : Behavior{
22 16

  
23 17
  public:
scout/libscout/src/helper_classes/ScoutPosition.cpp
1
#include "ScoutPosition.h"
2

  
3
using namespace std;
4

  
5
void pos::init()
6
{
7
  x = 0;
8
  y = 0;
9
  theta = 0;
10
  name = std::string("");
11
}
12

  
13
void pos::set_name(string new_name)
14
{
15
  name = string(new_name);
16
}
17

  
18
void pos::update(float new_x, float new_y, float new_t)
19
{
20
  x = new_x;
21
  y = new_y;
22
  theta = new_t;
23
}
scout/libscout/src/helper_classes/ScoutPosition.h
1
#ifndef _SCOUT_POSITION_
2
#define _SCOUT_POSITION_
3

  
4
#include <string>
5

  
6
struct pos
7
{
8
  float x;
9
  float y;
10
  float theta;
11
  std::string name;
12

  
13
  public:
14
  void init();
15
  void set_name(std::string new_name);
16
  void update(float new_x, float new_y, float new_t);
17
};
18

  
19
typedef struct pos pos;
20

  
21

  
22

  
23
#endif
scout/libscout/src/test_behaviors/Odometry_new.cpp
8 8
                Behavior(scoutname, "odometry", sensors)
9 9
{
10 10
  name = scoutname;
11
  scout_pos = new posi;
11
  scout_pos = new pos;
12 12

  
13 13
  encoder_readings scout_enc = encoders->query();
14 14
  motor_fl_ticks_last = motor_bl_ticks_last = scout_enc.fl_ticks;
scout/libscout/src/test_behaviors/Odometry_new.h
6 6
#include "../Behavior.h"
7 7
#include "../Sensors.h"
8 8
#include "messages/ScoutPosition.h"
9
#include "../helper_classes/ScoutPosition.h"
9 10

  
10 11
#define WHEEL_R 0.025 //this is a virtual unit now... use real values
11 12
#define WHEEL_B 0.115  // this is a virtual unit now... use real values
......
14 15
#define LOOP_RATE 10 // Hz, integrate 10 times per second
15 16
#define LOOP_TIME (1.0/LOOP_RATE) // secs
16 17

  
17
typedef struct{
18
  float x;
19
  float y;
20
  float theta;
21
} posi;
22

  
23 18
class Odometry_new : Behavior{
24 19

  
25 20
  public:
......
55 50
    int motor_br_ticks_last;
56 51
    int scout_theta;
57 52

  
58
    posi* scout_pos;
53
    pos* scout_pos;
59 54

  
60 55
};
61 56

  

Also available in: Unified diff