Skip to content

Commit

Permalink
add platoon-aware lane change model (MSLCM_LC2013_CC)
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-segata committed Apr 2, 2024
1 parent 3c595bc commit 395f726
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/microsim/lcmodels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set(microsim_lcmodels_STAT_SRCS
MSLCM_DK2008.h
MSLCM_LC2013.cpp
MSLCM_LC2013.h
MSLCM_LC2013_CC.cpp
MSLCM_LC2013_CC.h
MSLCM_SL2015.cpp
MSLCM_SL2015.h
)
Expand Down
3 changes: 3 additions & 0 deletions src/microsim/lcmodels/MSAbstractLaneChangeModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <microsim/devices/MSDevice_Bluelight.h>
#include "MSLCM_DK2008.h"
#include "MSLCM_LC2013.h"
#include "MSLCM_LC2013_CC.h"
#include "MSLCM_SL2015.h"
#include "MSAbstractLaneChangeModel.h"

Expand Down Expand Up @@ -86,6 +87,8 @@ MSAbstractLaneChangeModel::build(LaneChangeModel lcm, MSVehicle& v) {
return new MSLCM_DK2008(v);
case LaneChangeModel::LC2013:
return new MSLCM_LC2013(v);
case LaneChangeModel::LC2013_CC:
return new MSLCM_LC2013_CC(v);
case LaneChangeModel::SL2015:
return new MSLCM_SL2015(v);
case LaneChangeModel::DEFAULT:
Expand Down
50 changes: 50 additions & 0 deletions src/microsim/lcmodels/MSLCM_LC2013_CC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file MSLCM_LC2013.cpp
/// @author Daniel Krajzewicz
/// @author Jakob Erdmann
/// @author Friedemann Wesner
/// @author Sascha Krieg
/// @author Michael Behrisch
/// @author Laura Bieker
/// @author Leonhard Luecken
/// @date Fri, 08.10.2013
///
// A lane change model developed by J. Erdmann
// based on the model of D. Krajzewicz developed between 2004 and 2011 (MSLCM_DK2004)
/****************************************************************************/
#include "MSLCM_LC2013_CC.h"
#include <microsim/cfmodels/MSCFModel_CC.h>

// ===========================================================================
// member method definitions
// ===========================================================================
MSLCM_LC2013_CC::MSLCM_LC2013_CC(MSVehicle& v) : MSLCM_LC2013(v) {}

MSLCM_LC2013_CC::~MSLCM_LC2013_CC() {}

int MSLCM_LC2013_CC::checkChangeBeforeCommitting(const MSVehicle *veh, int state) const {

if (state & LCA_WANTS_LANECHANGE) {
auto *cfm = dynamic_cast<const MSCFModel_CC *>(&veh->getCarFollowModel());

if (cfm) {
bool left = (state & LCA_LEFT) != 0;
return cfm->isPlatoonLaneChangeSafe(veh, left);
}
}
return 0;
}

/****************************************************************************/
50 changes: 50 additions & 0 deletions src/microsim/lcmodels/MSLCM_LC2013_CC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file MSLCM_LC2013.h
/// @author Daniel Krajzewicz
/// @author Jakob Erdmann
/// @author Friedemann Wesner
/// @author Sascha Krieg
/// @author Michael Behrisch
/// @date Fri, 08.10.2013
///
// A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013
/****************************************************************************/
#pragma once

#include "MSLCM_LC2013.h"

// ===========================================================================
// class definitions
// ===========================================================================
/**
* @class MSLCM_LC2013_CC
* @brief A lane change model developed by D. Krajzewicz, J. Erdmann
* et al. between 2004 and 2013, extended for atomic lane change for platoons
*/
class MSLCM_LC2013_CC : public MSLCM_LC2013 {
public:

MSLCM_LC2013_CC(MSVehicle& v);

virtual ~MSLCM_LC2013_CC();

/// @brief Returns the model's id
LaneChangeModel getModelID() const override {
return LaneChangeModel::LC2013_CC;
}

int checkChangeBeforeCommitting(const MSVehicle* veh, int state) const override;

};
1 change: 1 addition & 0 deletions src/utils/xml/SUMOXMLDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ StringBijection<InsertionCheck>::Entry SUMOXMLDefinitions::insertionCheckValues[
StringBijection<LaneChangeModel>::Entry SUMOXMLDefinitions::laneChangeModelValues[] = {
{ "DK2008", LaneChangeModel::DK2008 },
{ "LC2013", LaneChangeModel::LC2013 },
{ "LC2013_CC", LaneChangeModel::LC2013_CC },
{ "SL2015", LaneChangeModel::SL2015 },
{ "default", LaneChangeModel::DEFAULT } //< must be the last one
};
Expand Down
1 change: 1 addition & 0 deletions src/utils/xml/SUMOXMLDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,7 @@ enum LaneChangeAction {
enum class LaneChangeModel {
DK2008,
LC2013,
LC2013_CC,
SL2015,
DEFAULT
};
Expand Down

0 comments on commit 395f726

Please sign in to comment.