Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
traci
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ezCar2X
ns3
traci
Commits
4981d368
Commit
4981d368
authored
4 years ago
by
Vishwanath Hugar
Committed by
Josef Jiru
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Add getRoute and setRoute APIs to SUMO"
parent
2c47a9f8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
model/traci-commands.h
+41
-0
41 additions, 0 deletions
model/traci-commands.h
model/traci-vehicle.cc
+25
-1
25 additions, 1 deletion
model/traci-vehicle.cc
model/traci-vehicle.h
+21
-0
21 additions, 0 deletions
model/traci-vehicle.h
with
87 additions
and
1 deletion
model/traci-commands.h
+
41
−
0
View file @
4981d368
...
...
@@ -460,6 +460,47 @@ private:
};
class
SetRoute
:
public
Command
{
public:
SetRoute
(
std
::
string
vehicle
,
StringList
edgeIdList
)
:
m_vehicle
(
vehicle
),
m_edgeIdList
(
edgeIdList
)
{
}
private
:
int
DoGetId
()
const
override
{
return
libsumo
::
CMD_SET_VEHICLE_VARIABLE
;
}
int
DoGetDataLength
()
const
override
{
return
1
+
CodingTraits
<
std
::
string
>::
Size
(
m_vehicle
)
+
1
+
CodingTraits
<
StringList
>::
Size
(
m_edgeIdList
);
}
bool
DoSerializeData
(
BufferType
&
buffer
)
const
override
{
CodingTraits
<
UByte
>::
Append
(
buffer
,
libsumo
::
VAR_ROUTE
);
CodingTraits
<
std
::
string
>::
Append
(
buffer
,
m_vehicle
);
CodingTraits
<
UByte
>::
Append
(
buffer
,
CodingTraits
<
StringList
>::
IDENTIFIER
);
CodingTraits
<
int
>::
Append
(
buffer
,
(
int
)
m_edgeIdList
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
m_edgeIdList
.
size
();
++
i
)
{
CodingTraits
<
std
::
string
>::
Append
(
buffer
,
m_edgeIdList
[
i
]);
}
return
true
;
}
std
::
string
m_vehicle
;
StringList
m_edgeIdList
;
};
}
// namespace command
}
// namespace traci
...
...
This diff is collapsed.
Click to expand it.
model/traci-vehicle.cc
+
25
−
1
View file @
4981d368
...
...
@@ -35,7 +35,7 @@ Vehicle::Vehicle (Ptr<TraCi> traci, std::string id)
m_speed
(
m_traci
,
id
),
m_speedLateral
(
m_traci
,
id
),
m_maxSpeed
(
m_traci
,
id
),
m_maxSpeedLateral
(
m_traci
,
id
),
m_heading
(
m_traci
,
id
),
m_acceleration
(
m_traci
,
id
),
m_maxAcceleration
(
m_traci
,
id
),
m_maxDeceleration
(
m_traci
,
id
),
m_laneIdx
(
m_traci
,
id
),
m_roadId
(
m_traci
,
id
),
m_color
(
m_traci
,
id
)
m_laneIdx
(
m_traci
,
id
),
m_roadId
(
m_traci
,
id
),
m_routeId
(
m_traci
,
id
),
m_route
(
m_traci
,
id
),
m_color
(
m_traci
,
id
)
{
}
...
...
@@ -175,6 +175,18 @@ Vehicle::GetRoadID (bool forceReload) const
return
m_roadId
.
GetValue
(
forceReload
);
}
std
::
string
Vehicle
::
GetRouteID
(
bool
forceReload
)
const
{
return
m_routeId
.
GetValue
(
forceReload
);
}
std
::
vector
<
std
::
string
>
Vehicle
::
GetRoute
(
bool
forceReload
)
const
{
return
m_route
.
GetValue
(
forceReload
);
}
Color
Vehicle
::
GetColor
(
bool
forceReload
)
const
{
...
...
@@ -243,6 +255,18 @@ Vehicle::moveToXY (std::string edgeID, int laneID, double x, double y, double an
m_traci
->
ExecuteCommand
(
my_command
,
my_result
);
}
void
Vehicle
::
setRoute
(
std
::
vector
<
std
::
string
>
edgeIdList
)
{
NS_LOG_INFO
(
"TraCiVehicle: Sending route to vehicle "
+
m_id
+
" : route = "
);
for
(
auto
const
&
edgeId
:
edgeIdList
)
{
NS_LOG_INFO
(
"EdgeId: "
+
edgeId
+
" "
);
}
traci
::
command
::
SetRoute
my_command
(
m_id
,
edgeIdList
);
traci
::
result
::
NoResult
my_result
;
m_traci
->
ExecuteCommand
(
my_command
,
my_result
);
}
}
}
This diff is collapsed.
Click to expand it.
model/traci-vehicle.h
+
21
−
0
View file @
4981d368
...
...
@@ -165,6 +165,14 @@ public:
std
::
string
GetRoadID
(
bool
forceReload
=
false
)
const
;
//! Get current route id
std
::
string
GetRouteID
(
bool
forceReload
=
false
)
const
;
//! Get route, edge list
std
::
vector
<
std
::
string
>
GetRoute
(
bool
forceReload
=
false
)
const
;
Color
GetColor
(
bool
forceReload
=
false
)
const
;
...
...
@@ -265,6 +273,17 @@ public:
void
moveToXY
(
std
::
string
edgeID
,
int
laneID
,
double
x
,
double
y
,
double
angle
=-
1000000.0
);
/*!
* @brief set route for vehicle.
*
* The first edge in the list has to be the one that the vehicle is at at the moment.
*
* Parameters:
* - new edgeId list
*/
void
setRoute
(
std
::
vector
<
std
::
string
>
edgeIdList
);
private:
Ptr
<
TraCi
>
m_traci
;
// link to the traci instance
std
::
string
m_id
;
// id of the object
...
...
@@ -287,6 +306,8 @@ private:
CachedVariable
<
double
,
libsumo
::
CMD_GET_VEHICLE_VARIABLE
,
libsumo
::
VAR_DECEL
>
m_maxDeceleration
;
CachedVariable
<
int
,
libsumo
::
CMD_GET_VEHICLE_VARIABLE
,
libsumo
::
VAR_LANE_INDEX
>
m_laneIdx
;
CachedVariable
<
std
::
string
,
libsumo
::
CMD_GET_VEHICLE_VARIABLE
,
libsumo
::
VAR_ROAD_ID
>
m_roadId
;
CachedVariable
<
std
::
string
,
libsumo
::
CMD_GET_VEHICLE_VARIABLE
,
libsumo
::
VAR_ROUTE_ID
>
m_routeId
;
CachedVariable
<
std
::
vector
<
std
::
string
>
,
libsumo
::
CMD_GET_VEHICLE_VARIABLE
,
libsumo
::
VAR_EDGES
>
m_route
;
CachedVariable
<
Color
,
libsumo
::
CMD_GET_VEHICLE_VARIABLE
,
libsumo
::
VAR_COLOR
>
m_color
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment