Project

General

Profile

Revision 518

fixed mutex unlock bug. made it so that if there is just one robot seen, it is assumed to be the robot requesting

View differences:

PositionMonitor.cpp
119 119
  return positionMap;
120 120
}
121 121

  
122
int PositionMonitor::getNumVisibleRobots() {
123
  return positionMap.size();
124
}
125

  
126
VisionPosition PositionMonitor::getFirstPosition(void) {
127
  return positionMap.begin()->second;
128
}
129

  
122 130
int PositionMonitor::getRobotPosition(int robot_id, int* xbuf, int* ybuf) {
123 131
  //TODO: figure out what a map returns if the element doesn't exist
124 132

  
125 133
  pthread_mutex_lock(&position_map_lock);
126 134

  
127 135
  if (positionMap.find(robot_id) == positionMap.end()){
136
    pthread_mutex_unlock(&position_map_lock);    
128 137
    return -1;
129
  }
138
  } else {
139
    VisionPosition pos = positionMap[robot_id];
130 140

  
131
  VisionPosition pos = positionMap[robot_id];
141
    pthread_mutex_unlock(&position_map_lock);
132 142

  
133
  pthread_mutex_unlock(&position_map_lock);
143
    *xbuf = pos.x;
144
    *ybuf = pos.y;
134 145

  
135
  *xbuf = pos.x;
136
  *ybuf = pos.y;
137

  
138
  return 0;
146
    return 0;
147
  }
139 148
}
140 149

  
141 150
bool PositionMonitor::isProbablySameRobot(VisionPosition p1, VisionPosition p2) {

Also available in: Unified diff