Skip to content

Commit 996d858

Browse files
committed
finally --working queues--, joining logic could still use some tuning and some parameters consilidated, but basic experiments can hopefully be done now
1 parent 970d801 commit 996d858

File tree

5 files changed

+36
-14
lines changed

5 files changed

+36
-14
lines changed

pedsim_simulator/include/pedsim_simulator/waitingqueue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class WaitingQueue
109109
void updateQueue ( double px, double py );
110110
void releaseAgent ( Agent* a );
111111
Ped::Tvector getQueueEnd();
112+
int getLastAgentId();
112113
};
113114

114115

pedsim_simulator/rviz/scene1.rviz

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Panels:
66
Expanded:
77
- /Grid1/Offset1
88
Splitter Ratio: 0.5
9-
Tree Height: 817
9+
Tree Height: 356
1010
- Class: rviz/Selection
1111
Name: Selection
1212
- Class: rviz/Tool Properties
@@ -125,22 +125,22 @@ Visualization Manager:
125125
Views:
126126
Current:
127127
Class: rviz/XYOrbit
128-
Distance: 75.9384
128+
Distance: 44.2378
129129
Enable Stereo Rendering:
130130
Stereo Eye Separation: 0.06
131131
Stereo Focal Distance: 1
132132
Swap Stereo Eyes: false
133133
Value: false
134134
Focal Point:
135-
X: 76.7738
136-
Y: 10.0154
137-
Z: 2.86065e-05
135+
X: 70.6832
136+
Y: 20.6308
137+
Z: 1.2394e-05
138138
Name: Current View
139139
Near Clip Distance: 0.01
140-
Pitch: 1.2304
140+
Pitch: 0.615401
141141
Target Frame: <Fixed Frame>
142142
Value: XYOrbit (rviz)
143-
Yaw: 4.70855
143+
Yaw: 1.55354
144144
Saved: ~
145145
Window Geometry:
146146
Displays:

pedsim_simulator/scenarios/scene1_queues.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<waypoint id="robot_goal" x="120" y="40" r="5"/>
2929
<waypoint id="robot_start" x="35" y="40" r="5"/>
3030

31-
<queue id="infodesk" x="50" y="20" direction="0"/>
32-
<queue id="checkpoint" x="90" y="15" direction="180"/>
31+
<queue id="infodesk" x="50" y="25" direction="0"/>
32+
<queue id="checkpoint" x="90" y="10" direction="3.142"/>
3333
<!--Attractions-->
3434
<!--Agents-->
3535
<agent x="60" y="20" n="1" dx="0" dy="0" type="0">

pedsim_simulator/src/scene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void Scene::updateQueues()
293293
q->getX(), q->getY(),
294294
a->getx(), a->gety() );
295295

296-
if ( d < 4.5 && coinFlip() > 0.5 )
296+
if ( d < 2.5 && coinFlip() > 0.5 )
297297
{
298298
q->enqueueAgent ( a );
299299
}

pedsim_simulator/src/waitingqueue.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,29 @@ WaitingQueue::~WaitingQueue()
7777

7878
void WaitingQueue::enqueueAgent ( Agent *a )
7979
{
80-
if ( queueing_agents_.size() == 15 ) //TEMP limit queue size
80+
if ( queueing_agents_.size() == 20 ) //TEMP limit queue size
8181
return;
8282

8383
// make the agent stop
8484
a->setStationary();
8585

8686
// set position to the end of the queue
87+
// NOTE - old way with setting positions
8788
Ped::Tvector qend = getQueueEnd();
8889
a->setPosition ( qend.x, qend.y );
8990

91+
// NOTE - new way with follow id
92+
// if ( queueing_agents_.size() == 0 )
93+
// {
94+
// Ped::Tvector qend = getQueueEnd();
95+
// a->setPosition ( qend.x, qend.y );
96+
// }
97+
// else
98+
// {
99+
// int follow_id = getLastAgentId();
100+
// a->setFollow(follow_id);
101+
// }
102+
90103
a->updateState( StateMachine::JOIN_QUEUE );
91104

92105
queueing_agents_.push_back ( a );
@@ -101,7 +114,7 @@ void WaitingQueue::serveAgent()
101114
releaseAgent ( lucky_one );
102115

103116
// update queue
104-
// updateQueue(lucky_one->getx(), lucky_one->gety());
117+
updateQueue(lucky_one->getx(), lucky_one->gety());
105118

106119
time_passed_ = 0;
107120
}
@@ -157,8 +170,8 @@ Ped::Tvector WaitingQueue::getQueueEnd()
157170
if ( queueing_agents_.size() == 0 )
158171
{
159172
return Ped::Tvector (
160-
x_ + ( buffer * cos ( theta_ ) ),
161-
y_ + ( buffer * sin ( theta_ ) ),
173+
x_ + ( buffer+1 * cos ( theta_ ) ),
174+
y_ + ( buffer+1 * sin ( theta_ ) ),
162175
0.0 );
163176
}
164177
else
@@ -169,4 +182,12 @@ Ped::Tvector WaitingQueue::getQueueEnd()
169182
last_one->gety() + ( buffer * sin ( theta_ ) ),
170183
0.0 );
171184
}
185+
}
186+
187+
int WaitingQueue::getLastAgentId()
188+
{
189+
if ( queueing_agents_.size() == 0 )
190+
return -1;
191+
else
192+
return queueing_agents_.back()->getid();
172193
}

0 commit comments

Comments
 (0)