Project

General

Profile

Revision dc742c14

IDdc742c140dd32eea71e8d73abafa3674079ba94e

Added by Alex Zirbel about 12 years ago

Fixed bugs and compiler warnings in old code.

View differences:

scout/libscout/CMakeLists.txt
30 30
#target_link_libraries(example ${PROJECT_NAME})
31 31

  
32 32
set(MAIN_FILES src/Behavior.cpp src/BehaviorList.cpp src/BehaviorProcess.cpp)
33
set(BEHAVIOR_FILES src/behaviors/Odometry.cpp src/behaviors/draw_cw_circle.cpp src/behaviors/draw_ccw_circle.cpp src/behaviors/navigationMap.cpp)
33
set(BEHAVIOR_FILES src/behaviors/Odometry.cpp src/behaviors/draw_cw_circle.cpp src/behaviors/draw_ccw_circle.cpp src/behaviors/navigationMap.cpp src/behaviors/sim_line.cpp)
34 34
set(TEST_BEHAVIOR_FILES src/behaviors/Scheduler.cpp src/behaviors/WH_Robot.cpp)
35 35
set(HELPER_FILES src/helper_classes/Order.cpp src/helper_classes/PQWrapper.cpp)
36 36
set(CONTROL_CLASSES src/MotorControl.cpp src/SonarControl.cpp src/HeadlightControl.cpp src/ButtonControl.cpp src/WirelessSender.cpp src/EncodersControl.cpp src/LinesensorControl.cpp)
scout/libscout/src/Behavior.cpp
48 48
 * @param scoutname If nonempty, specifies which scout in the simulator
49 49
 *                  will be controlled by this behavior.
50 50
 */
51
Behavior::Behavior(string scoutname, char* my_name)
51
Behavior::Behavior(string scoutname, string my_name)
52 52
{
53 53
    name = my_name;
54 54

  
scout/libscout/src/Behavior.h
55 55
{
56 56
    public:
57 57
        // Initializes ROS for behavior
58
        Behavior(std::string scoutname, char* name);
58
        Behavior(std::string scoutname, std::string name);
59 59

  
60 60
        /// Extended by subclasses to actually run the behavior.
61 61
        virtual void run() = 0;
62 62

  
63
        //Name of behaviour
64
        const char* name;
63
        // Name of behaviour
64
        std::string name;
65 65

  
66 66
    protected:
67 67
        ros::NodeHandle node;
scout/libscout/src/BehaviorList.cpp
6 6
  behavior_list.push_back((Behavior*)new draw_ccw_circle(scoutname));
7 7
  behavior_list.push_back((Behavior*)new Odometry(scoutname));
8 8
  behavior_list.push_back((Behavior*)new navigationMap(scoutname));
9
  behavior_list.push_back((Behavior*)new sim_line(scoutname));
9 10
//  behavior_list.push_back((Behavior*)new Scheduler(scoutname));
10 11
  return;
11 12
}
scout/libscout/src/BehaviorList.h
2 2
#define _BEHAVIOR_LIST_H_
3 3

  
4 4
#include "Behavior.h"
5
#include "behaviors/sim_line.h"
5 6
#include "behaviors/draw_cw_circle.h"
6 7
#include "behaviors/draw_ccw_circle.h"
7 8
#include "behaviors/Odometry.h"
scout/libscout/src/behaviors/Scheduler.cpp
66 66
    This function removes the order from assignedOrders. */
67 67
void Scheduler::task_complete(Order o)
68 68
{
69
    for (int i=0; i<assignedOrders.size(); i++)
69
    for (unsigned int i=0; i<assignedOrders.size(); i++)
70 70
	{
71 71
	    if (assignedOrders[i].getid()==o.getid())
72 72
		{
......
96 96
  double time = t.toSec();
97 97

  
98 98
  Order* best;
99
  for(int i=0; i<unassignedOrders->arraySize(); i++)
99
  for(unsigned int i=0; i<unassignedOrders->arraySize(); i++)
100 100
  {
101 101
    Order order = unassignedOrders->peek(i);
102 102

  
scout/libscout/src/helper_classes/PQWrapper.cpp
20 20
void PQWrapper::insert(Order o)
21 21
{
22 22

  
23
    int position=0;
23
    unsigned int position=0;
24 24
    bool foundPosition = false;
25 25
    while (!foundPosition && position < arrContents)
26 26
    {
......
37 37
    {
38 38
        if (arrContents<arrCapacity)
39 39
        {
40
            for (int i = arrContents; i >=position+1; i--) 
40
            for (unsigned int i = arrContents; i >=position+1; i--) 
41 41
            {
42 42
                minElems[i] = minElems[i-1];
43 43
            }            
......
47 47
        else 
48 48
        {
49 49
            pq.push(minElems[arrCapacity-1]);
50
            for (int i = arrContents-1; i >= position+1; i--) 
50
            for (unsigned int i = arrContents-1; i >= position+1; i--) 
51 51
            {
52 52
                minElems[i] = minElems[i-1];
53 53
            }            
......
71 71
{
72 72
    if (index >= arrContents) return minElems[-1];//TODO: can I return null?
73 73
    Order toDelete = minElems[index];
74
    for (int i = index; i < arrContents - 1; i++) 
74
    for (unsigned int i = index; i < arrContents - 1; i++) 
75 75
    {
76 76
        minElems[i] = minElems[i+1];
77 77
    }

Also available in: Unified diff