Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SocialAgents3D
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
ed23a69b
Commit
ed23a69b
authored
May 29, 2013
by
pitiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buggé limace 2D
parent
8bd8a582
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
66 additions
and
53 deletions
+66
-53
include/agent.h
include/agent.h
+1
-1
include/env_map.h
include/env_map.h
+2
-2
include/moving_mesh.h
include/moving_mesh.h
+1
-1
include/moving_obstacle.h
include/moving_obstacle.h
+1
-1
src/agent.cpp
src/agent.cpp
+14
-16
src/env_map.cpp
src/env_map.cpp
+1
-1
src/moving_mesh.cpp
src/moving_mesh.cpp
+4
-2
src/moving_obstacle.cpp
src/moving_obstacle.cpp
+28
-5
src/simulator.cpp
src/simulator.cpp
+7
-17
src/viewer.cpp
src/viewer.cpp
+7
-7
No files found.
include/agent.h
View file @
ed23a69b
...
...
@@ -8,7 +8,7 @@
#include "spatialHashing.h"
#define SECURED
//
#define SECURED
//#define EXPORTING_AGENT
//#define EXPORTING_OBJ
...
...
include/env_map.h
View file @
ed23a69b
...
...
@@ -32,9 +32,9 @@ class ArticulatedObstacle;
#include "pfp.h"
#define EXPORTING3
//
#define EXPORTING3
#define TWO_AND_HALF_DIM
//
#define TWO_AND_HALF_DIM
#ifdef EXPORTING3
...
...
include/moving_mesh.h
View file @
ed23a69b
...
...
@@ -18,7 +18,7 @@
using
namespace
std
;
#define EXPORTING2
//
#define EXPORTING2
float
get_angle3D
(
VEC3
v1
,
VEC3
v2
);
...
...
include/moving_obstacle.h
View file @
ed23a69b
...
...
@@ -14,7 +14,7 @@
#include "Algo/MovingObjects/particle_cell_2D_memo.h"
#endif
//
#define EXPORTING_BOXES
#define EXPORTING_BOXES
#ifdef EXPORTING_BOXES
#include "Algo/Render/GL2/mapRender.h"
...
...
src/agent.cpp
View file @
ed23a69b
...
...
@@ -21,12 +21,12 @@ float Agent::averageMaxSpeed_ = 2.0f ;
//float Agent::neighborDist_ = 20.0f ;
float Agent::neighborDistSq_ = neighborDist_ * neighborDist_ ;
//float Agent::radius_ = 8.0f ;
float
Agent
::
radius_
=
3.0
f
;
//
float Agent::radius_ = 1.5f ;
//
float Agent::radius_ = 3.0f ;
float Agent::radius_ = 1.5f ;
float Agent::timeHorizon_ = 10.0f ;
//float Agent::timeHorizon_ = 100.0f ;
float Agent::timeHorizonObst_ = 10.0f ;
float
Agent
::
range_
=
4
*
timeHorizonObst_
*
averageMaxSpeed_
+
radius_
;
float Agent::range_ =
2
*timeHorizonObst_ * averageMaxSpeed_ + radius_ ;
float Agent::rangeSq_ = range_ * range_ ;
unsigned int Agent::cptAgent = 0 ;
...
...
@@ -506,11 +506,13 @@ void Agent::update()
#endif
meanDirection_.set(0) ;
for (unsigned int i=0 ; i<SMOOTHING_BUFFER_SIZE ; ++i) {
meanDirection_ += meanVelocity_[i] ;
meanVelocity_[i] = meanVelocity_[(i+1)%SMOOTHING_BUFFER_SIZE] ;
}
meanVelocity_[SMOOTHING_BUFFER_SIZE-1] = velocity_ ;
meanDirection_.normalize() ;
}
...
...
@@ -751,7 +753,7 @@ void Agent::computeNewVelocity()
VEC3 normFace = VEC3 (0,0,1);
#endif
double collision_softening_factor;
float
ag_ambient_damping
=
5
0.0
;
float ag_ambient_damping =
1
0.0;
// double mass_var = 0.95;
// double average_mass = 1.0;
...
...
@@ -765,7 +767,7 @@ void Agent::computeNewVelocity()
double rand = 2.0*drand48()-1.0; // compris entre -1 et 1
// double ag_mass = average_mass*(1 + rand*mass_var); // valeurs uniformement réparties entre min et max
double
ag_mass
=
20
0.0
;
double ag_mass =
5
0.0;
/*
rand = 2.0*drand48()-1.0; // compris entre -1 et 1
radius_ = average_radius + rand*radius_var; // valeurs uniformement réparties entre min et max
...
...
@@ -805,7 +807,7 @@ void Agent::computeNewVelocity()
obst_radius_infl = 100.; // scenario 0
else
obst_radius_infl = 40.; // scenario 1 et 3
float
force_value
=
0.0
;
float force_value;
int nobst=0;
...
...
@@ -881,14 +883,13 @@ void Agent::computeNewVelocity()
// double fixed_obst_stiffness = 50000.0; // agent-obstacle interaction stiffness
double fixed_obst_stiffness = 5000.0; // agent-obstacle interaction stiffness
// double fixed_obst_damping = 1.0; // agent-obstacle interaction damping
int
fixed_obst_power
=
4.0
;
// the power to which elevate the agent-obstacle distance
int fixed_obst_power =
1
; // the power to which elevate the agent-obstacle distance
Obstacle* fixed_obst ;
for(std::vector<std::pair<float, Obstacle*> >::iterator it = obstacleNeighbors_.begin() ;
it != obstacleNeighbors_.end() ;
++it)
{
double dist = it->first;
// cerr << "nobst=" << nobst << "dist=" << dist << endl;
// double effective_range = 50*range_;
...
...
@@ -901,33 +902,29 @@ void Agent::computeNewVelocity()
}
fixed_obst=it->second ;
if(fixed_obst->mo!=NULL)
cerr << "Collision avec limace !!!" << endl;
VEC3 p1=fixed_obst->p1 ;
VEC3 p2=fixed_obst->p2 ;
vec=p2-p1;
vec.normalize();
norm= normFace ^vec;
forces -= force_value * norm;
// cerr << "obstacles fixes : nobst=" << nobst << " dist=" << dist << " force=" << force_value*norm << endl;
nobst++;
}
//----- forces dues à la répulsion des autres agents -------
double ag_stiffness = 400.0; // agent-agent interaction stiffness
double ag_damping = 1.0; // agent-agent interaction damping
double
ag_power
=
4.0
;
// the power to which elevate the agent-agent distance
// double ag_power = 1
; // the power to which elevate the agent-agent distance
rand = 2.0*drand48()-1.0; // compris entre -1 et 1
double radius_var = 0.5;
double ag_phys_radius_coef = 2.0*(1 + rand*radius_var); // valeurs uniformement réparties entre min et max
unsigned int nbA = 0 ;
for (std::vector<std::pair<float, Agent*> >::iterator it = agentNeighbors_.begin() ;
...
...
@@ -955,7 +952,8 @@ void Agent::computeNewVelocity()
if(dist < combinedRadius)
{
collision_softening_factor
=
pow
(
1
-
dist
/
combinedRadius
,
ag_power
);
// collision_softening_factor = pow(1-dist/combinedRadius,ag_power);
collision_softening_factor = 1;
float force_value = - ag_stiffness*collision_softening_factor*(combinedRadius-dist)
- ag_damping * (dist - previous_dist) / sim_->timeStep_;
...
...
src/env_map.cpp
View file @
ed23a69b
...
...
@@ -314,7 +314,7 @@ void EnvMap::initGL()
position_nmap
.
push_back
(
position_Export
);
TraversorV
<
PFP2
::
MAP
>
tV
(
*
nmap
);
//
TraversorV<PFP2::MAP> tV(*nmap);
// for(Dart d = tV.begin() ; d != tV.end() ; d = tV.next())
//// {
...
...
src/moving_mesh.cpp
View file @
ed23a69b
...
...
@@ -246,6 +246,7 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight, Dart d)
VEC3
axis
=
VEC3
(
0
,
0
,
1
)
^
normale
;
// Geom::translate(center[0],center[1],center[2],rot);
if
(
angle
!=
0
)
Geom
::
rotate
(
axis
,
angle
,
rot
)
;
for
(
Dart
dd
=
tv
.
begin
()
;
dd
!=
tv
.
end
()
;
dd
=
tv
.
next
())
...
...
@@ -264,6 +265,7 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight, Dart d)
axis
=
VEC3
(
0
,
0
,
1
)
^
normale
;
// Geom::translate(center[0],center[1],center[2],rot);
if
(
angle
!=
0
)
Geom
::
rotate
(
axis
,
angle
,
rot
)
;
for
(
unsigned
int
i
=
0
;
i
<
points
.
size
()
;
++
i
)
...
...
@@ -275,8 +277,8 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight, Dart d)
// std::cout << "fin " << points[i] << std::endl;
}
std
::
cout
<<
"nb vertices before simplification -> "
<<
points
.
size
()
<<
std
::
endl
;
std
::
cout
<<
"nb vertices after simplification -> "
<<
res
.
size
()
<<
std
::
endl
;
std
::
cout
<<
"nb vertices before simplification -> "
<<
points
.
size
()
<<
" ||"
<<
points
[
0
]
<<
std
::
endl
;
std
::
cout
<<
"nb vertices after simplification -> "
<<
res
.
size
()
<<
" ||"
<<
res
[
0
]
<<
std
::
endl
;
return
res
;
}
...
...
src/moving_obstacle.cpp
View file @
ed23a69b
...
...
@@ -147,9 +147,24 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
dInside
=
sim_
->
envMap_
.
getBelongingCell
(
pos
[
0
]);
#ifdef TWO_AND_HALF_DIM
parts_ = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>*[nbVertices+1];
if
(
!
rigid_
)
{
parts_
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2DAndHalf
<
PFP
>*
[
nbVertices
+
1
];
}
else
{
parts_
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2DAndHalf
<
PFP
>*
[
nbVertices
];
}
#else
if
(
!
rigid_
)
{
parts_
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2D
<
PFP
>*
[
nbVertices
+
1
];
}
else
{
parts_
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2D
<
PFP
>*
[
nbVertices
];
}
#endif
obstacles_
=
new
Obstacle
*
[
nbVertices
];
...
...
@@ -188,13 +203,21 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
center
/=
nbVertices
;
front
=
(
pos
[
0
]
+
pos
[
1
])
/
2
;
#ifdef TWO_AND_HALF_DIM
if
(
!
rigid_
)
{
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2DAndHalf
<
PFP
>*
part
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2DAndHalf
<
PFP
>
(
sim_
->
envMap_
.
map
,
dInside
,
center
,
sim_
->
envMap_
.
position
);
parts_
[
nbVertices
]
=
part
;
}
#else
#ifdef TWO_AND_HALF_DIM
CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>* part = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>(sim_->envMap_.map, dInside, center, sim_->envMap_.position);
if
(
!
rigid_
)
{
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2D
<
PFP
>*
part
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2D
<
PFP
>
(
sim_
->
envMap_
.
map
,
dInside
,
center
,
sim_
->
envMap_
.
position
);
parts_
[
nbVertices
]
=
part
;
}
#endif
// M appartient à l'ellipse ssi MF1 + MF2 = sum_dist_foci est une constante
// où F1 et F2 sont les deux foyers.
// length = (pos[0]-pos[1]).norm();
...
...
@@ -263,7 +286,7 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
//extrude face to build a cage
// compute edgeLength for mass-spring
hight=rigid_ ?
-10.0f :
10.0f;
hight
=
rigid_
?
10.0
f
:
-
10.0
f
;
Algo
::
Surface
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
groundFace
,
hight
)
;
// Dart dT = map.phi1(map.phi1(map.phi2(Dart(0))));
// std::cout << __FUNCTION__ << " val " << dT << std::endl;
...
...
src/simulator.cpp
View file @
ed23a69b
...
...
@@ -71,7 +71,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
case
3
:
envMap_
.
init
(
config
,
1000.0
f
,
1000.0
f
,
minSize
,
100.0
f
)
;
//grosses cases
setupScenario
(
nbAgent
,
false
)
;
addMovingObstacles(nbObst, 1);
addMovingObstacles
(
nbObst
,
1
,
10
);
addPathToObstacles
(
envMap_
.
buildingMark
,
true
);
//// setupCityScenario(-1.0f * (12 * (70.0f / 2.0f) - 10),
//// -1.0f * (12 * (70.0f / 2.0f) - 10), 20, 20);
...
...
@@ -708,7 +708,7 @@ void Simulator::setupScenario(unsigned int nbMaxAgent, bool pedWay)
TraversorF
<
PFP
::
MAP
>
tF
(
envMap_
.
map
);
d
=
tF
.
begin
()
;
unsigned int nbx =
nbMaxAgent==0 ? 1 : (nbMaxAgent / (nb_cells))/5
;
unsigned
int
nbx
=
1
;
unsigned
int
nby
=
5
;
...
...
@@ -888,10 +888,10 @@ void Simulator::addMovingObstacle(Dart d, unsigned int obstType)
vPos
.
push_back
(
start
+
xSideF
*
dir1
+
ySideF
*
dir2
);
vPos
.
push_back
(
start
-
xSideF
*
dir1
+
ySideF
*
dir2
);
#else
vPos.push_back(start-xSide-ySide);
vPos.push_back(start+xSide-ySide);
vPos
.
push_back
(
start
+
xSide
+
ySide
);
vPos.push_back(start-xSide+ySide);
vPos
.
push_back
(
start
+
xSide
-
ySide
);
vPos
.
push_back
(
start
-
xSide
-
ySide
);
vPos
.
push_back
(
start
-
xSide
+
ySide
);
#endif
}
...
...
@@ -905,17 +905,7 @@ void Simulator::addMovingObstacle(Dart d, unsigned int obstType)
movingMeshes_
.
push_back
(
mm
);
vPos
=
mm
->
computeProjectedPointSet
(
maxHeight
,
d
);
std
::
reverse
(
vPos
.
begin
(),
vPos
.
end
());
#ifndef TWO_AND_HALF_DIM
//scale projected pointset
VEC3 bary(0);
for(std::vector<VEC3>::iterator it = vPos.begin() ; it != vPos.end() ; ++it)
bary += *it;
bary /= vPos.size();
float scale =1.2f;
for(std::vector<VEC3>::iterator it = vPos.begin() ; it != vPos.end() ; ++it)
*it = *it*scale - bary*(scale-1.0f);
#endif
std
::
cout
<<
"créé limace"
<<
std
::
endl
;
}
break
;
...
...
@@ -958,7 +948,7 @@ void Simulator::addMovingObstacle(Dart d, unsigned int obstType)
MovingObstacle
*
mo
=
new
MovingObstacle
(
this
,
movingObstacles_
.
size
(),
vPos
,
goals
,
(
obstType
==
0
),
(
obstType
==
0
),
0
,
d
);
std
::
cout
<<
"créé obstacle : "
<<
vPos
[
0
]
<<
std
::
endl
;
movingObstacles_
.
push_back
(
mo
);
...
...
src/viewer.cpp
View file @
ed23a69b
...
...
@@ -2138,13 +2138,13 @@ int main(int argc, char** argv)
// S'il y a un cam input file, alors lire le premier
// entier N et faire marcher la simulation N fois.
//
sa.readCameraInputFile("src/cam.scn3.spline");
//
sa.cam_output_file.open("src/cam.out",std::ofstream::out);
// sa.cam_output_file("src/cam.out");
//
int i;
//
for(i=0;i<sa.cif_begin;i++)
//
sa.animate();
//
sa.readCameraInputFile("src/cam.scn3.spline");
//
sa.cam_output_file.open("src/cam.out",std::ofstream::out);
//
//
// unsigned
int i;
//
for(i=0;i<sa.cif_begin;i++)
sa.animate();
return app.exec() ;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment