diff --git a/subt_ign/launch/competition.ign b/subt_ign/launch/competition.ign index f03cb8cb..8bcf4b63 100644 --- a/subt_ign/launch/competition.ign +++ b/subt_ign/launch/competition.ign @@ -67,14 +67,9 @@ # CommsBrokerPlugin parameters # (default parameters can be found in subt_rf_model.h) - $commsFadingExponent = 2.5 - $commsScalingFactor = 1.0 + $commsFadingExponent = 1.5 + $commsScalingFactor = 0.55 $commsRangePerHop = 2.0 - if $circuit == "cave" || $circuit == "finals" - $commsFadingExponent = 1.5 - $commsScalingFactor = 0.55 - $commsRangePerHop = 2.0 - end # spawn world offset if $circuit == "urban" diff --git a/subt_ign/src/ConnectionHelper.cc b/subt_ign/src/ConnectionHelper.cc index 6dfd4d02..4389d8c9 100644 --- a/subt_ign/src/ConnectionHelper.cc +++ b/subt_ign/src/ConnectionHelper.cc @@ -364,6 +364,160 @@ std::map {"4-Way Finals Transition 2 Lights", subt::ConnectionHelper::TURN}, }; + std::map + subt::ConnectionHelper::circuitTypes = + { + {"Tunnel Tile 1", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 1 Lights", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 2", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 2 Lights", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 3", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 3 Lights", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 4", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 4 Lights", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 5", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 5 Lights", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 6", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 6 Lights", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 7", subt::ConnectionHelper::TUNNEL}, + {"Tunnel Tile 7 Lights", subt::ConnectionHelper::TUNNEL}, + {"Urban Straight", subt::ConnectionHelper::URBAN}, + {"Urban Straight Lights", subt::ConnectionHelper::URBAN}, + {"Urban Bend Right", subt::ConnectionHelper::URBAN}, + {"Urban Bend Left", subt::ConnectionHelper::URBAN}, + {"Urban Bend Left Lights", subt::ConnectionHelper::URBAN}, + {"Urban Superpose", subt::ConnectionHelper::URBAN}, + {"Urban 3-Way Right Intersection", subt::ConnectionHelper::URBAN}, + {"Urban Straight Door Right", subt::ConnectionHelper::URBAN}, + {"Urban Straight Door Left", subt::ConnectionHelper::URBAN}, + {"Urban Straight Door Right Flipped", subt::ConnectionHelper::URBAN}, + {"Urban Straight Door Right Flipped Lights", + subt::ConnectionHelper::URBAN}, + {"Urban Straight Door Left Flipped", subt::ConnectionHelper::URBAN}, + {"Urban Straight Door Right Extension", subt::ConnectionHelper::URBAN}, + {"Urban Straight Door Right Extension Lights", + subt::ConnectionHelper::URBAN}, + {"Urban Service Room Centered", subt::ConnectionHelper::URBAN}, + {"Urban Service Room Centered Lights", subt::ConnectionHelper::URBAN}, + {"Urban Service Room", subt::ConnectionHelper::URBAN}, + {"Urban Service Room Lights", subt::ConnectionHelper::URBAN}, + {"Urban Service Room Straight", subt::ConnectionHelper::URBAN}, + {"Urban Service Room Straight Lights", subt::ConnectionHelper::URBAN}, + {"Urban Platform", subt::ConnectionHelper::URBAN}, + {"Urban Platform Open", subt::ConnectionHelper::URBAN}, + {"Urban Stairwell Platform", subt::ConnectionHelper::URBAN}, + {"Urban Stairwell Platform Lights", subt::ConnectionHelper::URBAN}, + {"Urban Stairwell Platform Centered", subt::ConnectionHelper::URBAN}, + {"Urban Stairwell Platform Centered Lights", + subt::ConnectionHelper::URBAN}, + {"Urban Starting Area", subt::ConnectionHelper::URBAN}, + {"Urban Elevation Up", subt::ConnectionHelper::URBAN}, + {"Urban Elevation Up Lights", subt::ConnectionHelper::URBAN}, + {"Urban Elevation Down", subt::ConnectionHelper::URBAN}, + {"Urban 2 Story", subt::ConnectionHelper::URBAN}, + {"Urban 2 Story Lights", subt::ConnectionHelper::URBAN}, + {"Urban 2 Story Large Side 1 Lights", subt::ConnectionHelper::URBAN}, + {"Urban 2 Story Large Side 2 Lights", subt::ConnectionHelper::URBAN}, + {"Urban 2 Story Large Side 1", subt::ConnectionHelper::URBAN}, + {"Urban 2 Story Large Side 2", subt::ConnectionHelper::URBAN}, + {"Urban Large Room Split", subt::ConnectionHelper::URBAN}, + {"Urban Large Room Split Lights", subt::ConnectionHelper::URBAN}, + {"Cave Starting Area Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 01 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 01 Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 02 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 02 Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 03 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 04 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 04 Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 05 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Straight 05 Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 01 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 01 Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 02 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 02 Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way 01 Type B", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way 01 Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Elevation Type B", subt::ConnectionHelper::CAVE}, + {"Cave Elevation Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Type B", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Cavern Split 01 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Cavern Split 02 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 30 Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 30F Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 30 D Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 30 D Lights Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 30F D Type B", subt::ConnectionHelper::CAVE}, + {"Cave Corner 30F D Lights Type B", subt::ConnectionHelper::CAVE}, + + {"Cave 2 Way 01 Type A", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way 01 Type A", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way 02 Type A", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way Elevation 01 Type A", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way Elevation 02 Type A", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way Elevation 03 Type A", subt::ConnectionHelper::CAVE}, + {"Cave 4 Way 01 Type A", subt::ConnectionHelper::CAVE}, + {"Cave Cavern Type A", subt::ConnectionHelper::CAVE}, + {"Cave Corner 01 Type A", subt::ConnectionHelper::CAVE}, + {"Cave Corner 02 Type A", subt::ConnectionHelper::CAVE}, + {"Cave Corner 03 Type A", subt::ConnectionHelper::CAVE}, + {"Cave Corner 03 Type A Lights", subt::ConnectionHelper::CAVE}, + {"Cave Corner 04 Type A", subt::ConnectionHelper::CAVE}, + {"Cave Cap Type A", subt::ConnectionHelper::CAVE}, + {"Cave Elevation 01 Type A", subt::ConnectionHelper::CAVE}, + {"Cave Elevation 02 Type A", subt::ConnectionHelper::CAVE}, + {"Cave Elevation Corner Type A", subt::ConnectionHelper::CAVE}, + {"Cave Elevation Straight Type A", subt::ConnectionHelper::CAVE}, + {"Cave Split Type A", subt::ConnectionHelper::CAVE}, + {"Cave Straight Shift Type A", subt::ConnectionHelper::CAVE}, + {"Cave Straight Type A", subt::ConnectionHelper::CAVE}, + {"Cave U Turn 01 Type A", subt::ConnectionHelper::CAVE}, + {"Cave U Turn Elevation Type A", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Cantilevered Type A", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Straight Bottom Type A", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Straight Top Type A", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Type A", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Dead End Type A", subt::ConnectionHelper::CAVE}, + {"Cave 3 Way Elevation 02 Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave 4 Way 01 Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave Corner 01 Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave Corner 02 Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave Corner 04 Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave Elevation Straight Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave Straight Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave U Turn Elevation Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave Vertical Shaft Straight Bottom Lights Type A", subt::ConnectionHelper::CAVE}, + {"Cave Transition Type A to and from Type B", subt::ConnectionHelper::CAVE}, + {"Cave Transition Type A to and from Type B Lights", subt::ConnectionHelper::CAVE}, + + {"Jenolan Section 01", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 02", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 03", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 04", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 05", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 06", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 07", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 08", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 09", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 10", subt::ConnectionHelper::CAVE}, + {"Jenolan Section 11", subt::ConnectionHelper::CAVE}, + {"Universal Straight 10", subt::ConnectionHelper::UNIVERSAL}, + {"Universal Straight 5", subt::ConnectionHelper::UNIVERSAL}, + {"Universal Straight 2.5", subt::ConnectionHelper::UNIVERSAL}, + {"Universal Shift 5x5", subt::ConnectionHelper::UNIVERSAL}, + {"Universal Shift 2.5x2.5", subt::ConnectionHelper::UNIVERSAL}, + {"Cave Tunnel Transition", subt::ConnectionHelper::TRANSITION}, + {"Cave Tunnel Transition Lights", subt::ConnectionHelper::TRANSITION}, + {"Urban Cave Transition", subt::ConnectionHelper::TRANSITION}, + {"Urban Cave Transition Straight", subt::ConnectionHelper::TRANSITION}, + {"Urban Tunnel Transition", subt::ConnectionHelper::TRANSITION}, + {"Finals Staging Area", subt::ConnectionHelper::STAGING_AREA}, + {"4-Way Finals Transition", subt::ConnectionHelper::TRANSITION}, + {"4-Way Finals Transition 2", subt::ConnectionHelper::TRANSITION}, + {"4-Way Finals Transition 2 Lights", subt::ConnectionHelper::TRANSITION}, + }; + using namespace ignition; using namespace subt; diff --git a/subt_ign/src/ConnectionHelper.hh b/subt_ign/src/ConnectionHelper.hh index 28c41033..354ac200 100644 --- a/subt_ign/src/ConnectionHelper.hh +++ b/subt_ign/src/ConnectionHelper.hh @@ -55,6 +55,23 @@ namespace subt TURN = 1, }; + /// \brief Enum of circuit type + public: enum CircuitType + { + /// \brief Tunnel tiles + TUNNEL = 0, + /// \brief Urban tiles + URBAN = 1, + /// \brief Cave tiles + CAVE = 2, + /// \brief Universal tiles + UNIVERSAL = 3, + /// \brief Transition tiles + TRANSITION = 4, + /// \brief Staging are + STAGING_AREA = 5, + }; + /// \brief Compute the connection point between two tiles. /// This uses a reference list of connection points for each tile type. /// The function iterates over the connection points transformed into the @@ -75,6 +92,10 @@ namespace subt /// \brief Map of tile type to connection type public: static std::map connectionTypes; + + /// \brief Map of tile type to circuit type + public: static std::map + circuitTypes; }; } #endif diff --git a/subt_ign/src/apps/dot_generator.cc b/subt_ign/src/apps/dot_generator.cc index a46a441a..7ad499d0 100644 --- a/subt_ign/src/apps/dot_generator.cc +++ b/subt_ign/src/apps/dot_generator.cc @@ -22,10 +22,19 @@ using namespace subt; using namespace ignition; +/// \brief Print usage +void usage() +{ + std::cerr << "Usage: dot_generator [--finals] " + << std::endl; +} + /// \brief Print the DOT file /// \param[in] _vertexData vector of vertex data containing /// vertex and edge info -void printGraph(std::vector &_vertexData) +/// \param[in] _circuit Empty string or "--finals" . +void printGraph(std::vector &_vertexData, + const std::string &_circuit) { std::stringstream out; out << "/* Visibility graph generated by dot_generator */\n\n"; @@ -80,6 +89,22 @@ void printGraph(std::vector &_vertexData) auto tp2 = subt::ConnectionHelper::connectionTypes[_vertexData[j].tileType]; + // Get the circuit type for each tile (cave, urban, etc.) + auto ct1It = subt::ConnectionHelper::circuitTypes.find( + _vertexData[i].tileType); + if (ct1It == subt::ConnectionHelper::circuitTypes.end()) + { + ignwarn << "No circuit information for: " << _vertexData[i].tileType + << std::endl; + } + auto ct2It = subt::ConnectionHelper::circuitTypes.find( + _vertexData[j].tileType); + if (ct2It == subt::ConnectionHelper::circuitTypes.end()) + { + ignwarn << "No circuit information for: " << _vertexData[j].tileType + << std::endl; + } + // Is one of the tile a starting area? If so, the cost should be 1. bool connectsToStaging = _vertexData[i].tileType == "Cave Starting Area Type B" || @@ -93,12 +118,42 @@ void printGraph(std::vector &_vertexData) cost = 1; else if (tp1 == subt::ConnectionHelper::TURN && tp2 == subt::ConnectionHelper::STRAIGHT) - cost = 3; + { + // Both tiles are tunnels + if (_circuit == "--finals" && + ct1It != subt::ConnectionHelper::circuitTypes.end() && + ct1It->second == subt::ConnectionHelper::TUNNEL && + ct2It != subt::ConnectionHelper::circuitTypes.end() && + ct2It->second == subt::ConnectionHelper::TUNNEL) + cost = 2; + else + cost = 3; + } else if (tp1 == subt::ConnectionHelper::STRAIGHT && tp2 == subt::ConnectionHelper::TURN) - cost = 3; + { + // Both tiles are tunnels + if (_circuit == "--finals" && + ct1It != subt::ConnectionHelper::circuitTypes.end() && + ct1It->second == subt::ConnectionHelper::TUNNEL && + ct2It != subt::ConnectionHelper::circuitTypes.end() && + ct2It->second == subt::ConnectionHelper::TUNNEL) + cost = 2; + else + cost = 3; + } else - cost = 6; + { + // Both tiles are tunnels + if (_circuit == "--finals" && + ct1It != subt::ConnectionHelper::circuitTypes.end() && + ct1It->second == subt::ConnectionHelper::TUNNEL && + ct2It != subt::ConnectionHelper::circuitTypes.end() && + ct2It->second == subt::ConnectionHelper::TUNNEL) + cost = 3; + else + cost = 6; + } if (connectsToStaging) out << " /* Base station */\n"; @@ -120,7 +175,7 @@ void printGraph(std::vector &_vertexData) /// \brief Main function to generate DOT from input sdf file /// \param[in] _sdfFile Input sdf file. -void generateDOT(const std::string &_sdfFile) +void generateDOT(const std::string &_sdfFile, const std::string &_circuit) { std::ifstream file(_sdfFile); if (!file.is_open()) @@ -155,7 +210,7 @@ void generateDOT(const std::string &_sdfFile) str = str.substr(result); } - printGraph(vertexData); + printGraph(vertexData, _circuit); file.close(); } @@ -163,14 +218,41 @@ void generateDOT(const std::string &_sdfFile) ////////////////////////////////////////////////// int main(int argc, char **argv) { - if (argc != 2) + if (argc != 2 && argc != 3) { - std::cerr << "Usage: dot_generator " - << std::endl; + usage(); return -1; } + + std::string circuit = ""; std::string sdfFile = argv[1]; - generateDOT(sdfFile); + + if (argc == 2) + { + // Sanity check: --finals can't be used without the sdfFile argument. + if (argv[1] == std::string("--finals")) + { + usage(); + return -1; + } + } + + if (argc == 3) + { + // Sanity check: One of the two arguments needs to be --finals. + if (argv[1] != std::string("--finals") && + argv[2] != std::string("--finals")) + { + usage(); + return -1; + } + + circuit = "--finals"; + if (argv[1] == std::string("--finals")) + sdfFile = argv[2]; + } + + generateDOT(sdfFile, circuit); return 0; } diff --git a/subt_ign/worlds/finals_qual.dot b/subt_ign/worlds/finals_qual.dot index 861222dc..74504fe2 100644 --- a/subt_ign/worlds/finals_qual.dot +++ b/subt_ign/worlds/finals_qual.dot @@ -22,7 +22,6 @@ graph { 14 [label="14::Universal Shift 5x5::tile_14"]; 15 [label="15::Universal Straight 2.5::tile_15"]; 16 [label="16::Universal Straight 5::tile_16"]; - 17 [label="17::Tunnel Tile Blocker::tile_17"]; 18 [label="18::Cave Cap Type A::tile_18"]; 19 [label="19::Cave Corner 01 Type A::tile_19"]; 20 [label="20::Cave 3 Way 01 Type A::tile_20"]; @@ -43,9 +42,7 @@ graph { 36 [label="36::Cave Cap Type A::tile_36"]; 37 [label="37::Cave 2 Way 01 Type A::tile_37"]; 38 [label="38::Cave Elevation 02 Type A::tile_38"]; - 39 [label="39::Tunnel Tile Blocker::tile_39"]; 40 [label="40::Tunnel Tile 5::tile_40"]; - 41 [label="41::Tunnel Tile Blocker::tile_41"]; 42 [label="42::Tunnel Tile 5::tile_42"]; 43 [label="43::Tunnel Tile 2::tile_43"]; 44 [label="44::Tunnel Tile 6::tile_44"]; @@ -53,7 +50,6 @@ graph { 46 [label="46::Cave Transition Type A to and from Type B::tile_46"]; 47 [label="47::Tunnel Tile 6::tile_47"]; 48 [label="48::Tunnel Tile 2::tile_48"]; - 49 [label="49::Tunnel Tile Blocker::tile_49"]; 50 [label="50::Tunnel Tile 6::tile_50"]; 51 [label="51::Tunnel Tile 2::tile_51"]; 52 [label="52::Tunnel Tile 4::tile_52"]; @@ -62,7 +58,6 @@ graph { 55 [label="55::Cave Corner 03 Type A Lights::tile_55"]; 56 [label="56::Cave Cap Type A::tile_56"]; 57 [label="57::Cave Tunnel Transition Lights::tile_57"]; - 58 [label="58::Tunnel Tile Blocker::tile_58"]; 59 [label="59::Tunnel Tile 7 Lights::tile_59"]; 60 [label="60::Tunnel Tile 1 Lights::tile_60"]; 61 [label="61::Tunnel Tile 5 Lights::tile_61"]; @@ -77,15 +72,10 @@ graph { 70 [label="70::Urban Large Room Split Lights::tile_70"]; 71 [label="71::Urban Cave Transition::tile_71"]; 72 [label="72::Urban Elevation Up::tile_72"]; - 73 [label="73::Tunnel Tile Blocker::tile_73"]; 74 [label="74::Urban 3-Way Right Intersection::tile_74"]; 75 [label="75::Urban Service Room Straight Lights::tile_75"]; 76 [label="76::Urban Service Room Straight Lights::tile_76"]; 77 [label="77::Urban 2 Story Lights::tile_77"]; - 78 [label="78::Tunnel Tile Blocker::tile_78"]; - 79 [label="79::Tunnel Tile Blocker::tile_79"]; - 80 [label="80::Tunnel Tile Blocker::tile_80"]; - 81 [label="81::Tunnel Tile Blocker::tile_81"]; 82 [label="82::Cave Cap Type A::tile_82"]; /* ==== Edges ==== */ @@ -114,9 +104,9 @@ graph { 18 -- 57 [label=3]; 20 -- 21 [label=6]; 20 -- 55 [label=6]; - 22 -- 23 [label=6]; + 22 -- 23 [label=2]; 22 -- 57 [label=3]; - 23 -- 59 [label=6]; + 23 -- 59 [label=2]; 24 -- 31 [label=3]; 25 -- 32 [label=3]; 26 -- 66 [label=1]; @@ -136,26 +126,26 @@ graph { 38 -- 64 [label=3]; 40 -- 42 [label=1]; 42 -- 47 [label=1]; - 43 -- 50 [label=3]; - 43 -- 51 [label=6]; - 44 -- 45 [label=3]; - 44 -- 51 [label=3]; - 45 -- 52 [label=6]; - 45 -- 53 [label=6]; + 43 -- 50 [label=2]; + 43 -- 51 [label=2]; + 44 -- 45 [label=2]; + 44 -- 51 [label=2]; + 45 -- 52 [label=2]; + 45 -- 53 [label=2]; 46 -- 65 [label=3]; 46 -- 71 [label=1]; - 47 -- 48 [label=3]; - 48 -- 54 [label=6]; - 50 -- 52 [label=3]; - 52 -- 54 [label=6]; - 53 -- 54 [label=6]; - 54 -- 61 [label=3]; + 47 -- 48 [label=2]; + 48 -- 54 [label=2]; + 50 -- 52 [label=2]; + 52 -- 54 [label=2]; + 53 -- 54 [label=2]; + 54 -- 61 [label=2]; 55 -- 57 [label=3]; 56 -- 64 [label=6]; - 59 -- 60 [label=6]; - 60 -- 61 [label=3]; - 60 -- 62 [label=6]; - 62 -- 63 [label=3]; + 59 -- 60 [label=2]; + 60 -- 61 [label=2]; + 60 -- 62 [label=2]; + 62 -- 63 [label=2]; 66 -- 67 [label=3]; 67 -- 70 [label=6]; 68 -- 69 [label=3];