-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simplify_map feature, as well as benchmark. New simplify_map ca…
…n speed up performance 10-20%, and is baseline faster at =0
- Loading branch information
1 parent
238bc03
commit 6601c65
Showing
19 changed files
with
444 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<launch> | ||
|
||
<!-- | ||
You can override these default values: | ||
roslaunch flatland_Server server.launch world_path:="/some/world.yaml" initial_rate:="30.0" | ||
--> | ||
<arg name="world_path" default="$(find flatland_server)/test/benchmark_world/world.yaml"/> | ||
<arg name="update_rate" default="200.0"/> | ||
<arg name="step_size" default="0.005"/> | ||
<arg name="benchmark_duration" default="60.0"/> | ||
<arg name="use_perf" default="false" /> | ||
<arg name="show_viz" default="true" /> | ||
<arg name="simplify_map" default="2" /> <!-- 0=None, 1=moderately, 2=significantly--> | ||
|
||
<env name="ROSCONSOLE_FORMAT" value="[${severity} ${time} ${logger}]: ${message}" /> | ||
|
||
<param name="use_sim_time" value="true"/> | ||
|
||
<!-- launch flatland benchmark --> | ||
<!-- /usr/lib/linux-tools/5.4.0-173-generic/perf on my local container --> | ||
<node name="flatland_benchmark" pkg="flatland_server" type="flatland_benchmark" output="screen" required="true" | ||
launch-prefix="$(eval 'perf record --call-graph dwarf --output=perf.out.flatland_benchmark.data --' if arg('use_perf') else '')" | ||
> | ||
<!-- Use the arguments passed into the launchfile for this node --> | ||
<param name="world_path" value="$(arg world_path)" /> | ||
<param name="update_rate" value="$(arg update_rate)" /> | ||
<param name="step_size" value="$(arg step_size)" /> | ||
<param name="show_viz" value="$(arg show_viz)" /> | ||
<param name="benchmark_duration" value="$(arg benchmark_duration)" /> | ||
<param name="simplify_map" value="$(arg simplify_map)" /> | ||
</node> | ||
|
||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* | ||
* ______ __ __ __ | ||
* /\ _ \ __ /\ \/\ \ /\ \__ | ||
* \ \ \L\ \ __ __ /\_\ \_\ \ \ \____ ___\ \ ,_\ ____ | ||
* \ \ __ \/\ \/\ \\/\ \ /'_` \ \ '__`\ / __`\ \ \/ /',__\ | ||
* \ \ \/\ \ \ \_/ |\ \ \/\ \L\ \ \ \L\ \/\ \L\ \ \ \_/\__, `\ | ||
* \ \_\ \_\ \___/ \ \_\ \___,_\ \_,__/\ \____/\ \__\/\____/ | ||
* \/_/\/_/\/__/ \/_/\/__,_ /\/___/ \/___/ \/__/\/___/ | ||
* @copyright Copyright 2024 Avidbots Corp. | ||
* @name flatland_benchmark.cpp | ||
* @brief Benchmark version of flatland_server | ||
* @author Joseph Duchesne | ||
* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2024, Avidbots Corp. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of the Avidbots Corp. nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include <ros/ros.h> | ||
#include <signal.h> | ||
#include <string> | ||
|
||
#include "flatland_server/simulation_manager.h" | ||
|
||
/** Global variables */ | ||
flatland_server::SimulationManager *simulation_manager; | ||
double benchmark_duration = 10.0; // overwritten by rosparam "benchmark_duration" if set | ||
double benchmark_start = 0.0f; | ||
|
||
/** | ||
* @name SigintHandler | ||
* @brief Interrupt handler - sends shutdown signal to simulation_manager | ||
* @param[in] sig: signal itself | ||
*/ | ||
void SigintHandler(int sig) { | ||
ROS_WARN_NAMED("Benchmark", "*** Shutting down... ***"); | ||
|
||
if (simulation_manager != nullptr) { | ||
simulation_manager->Shutdown(); | ||
delete simulation_manager; | ||
simulation_manager = nullptr; | ||
} | ||
ROS_INFO_STREAM_NAMED("Benchmark", "Beginning ros shutdown"); | ||
ros::shutdown(); | ||
} | ||
|
||
void CheckTimeout(const ros::WallTimerEvent& timer_event) { | ||
double elapsed = simulation_manager->timekeeper_.GetSimTime().toSec(); | ||
if (elapsed >= benchmark_duration) { | ||
double bench_time = ros::WallTime::now().toSec() - benchmark_start; | ||
ROS_INFO_NAMED("Benchmark", "Benchmark complete. Ran %ld iterations in %.3f sec; %.3f iter/sec. Shutting down.", | ||
simulation_manager->iterations_, bench_time, (double)(simulation_manager->iterations_)/bench_time); | ||
ros::shutdown(); | ||
} | ||
ROS_INFO_THROTTLE_NAMED(1.0, "Benchmark", "Elapsed: %.1f/%.1f.", elapsed, benchmark_duration); | ||
} | ||
|
||
/** | ||
* @name main | ||
* @brief Entrypoint for Flatland Server ros node | ||
*/ | ||
int main(int argc, char **argv) { | ||
ros::init(argc, argv, "flatland", ros::init_options::NoSigintHandler); | ||
ros::NodeHandle node_handle("~"); | ||
|
||
// todo: Load default parameters, run on a specific (default incl.) map for N seconds, then report. | ||
|
||
// Load parameters | ||
std::string world_path; // The file path to the world.yaml file | ||
if (!node_handle.getParam("world_path", world_path)) { | ||
ROS_FATAL_NAMED("Benchmark", "No world_path parameter given!"); | ||
ros::shutdown(); | ||
return 1; | ||
} | ||
|
||
float update_rate = 200.0; // The physics update rate (Hz) | ||
node_handle.getParam("update_rate", update_rate); | ||
|
||
float step_size = 1 / 200.0; | ||
node_handle.getParam("step_size", step_size); | ||
|
||
bool show_viz = false; | ||
node_handle.getParam("show_viz", show_viz); | ||
|
||
float viz_pub_rate = 30.0; | ||
node_handle.getParam("viz_pub_rate", viz_pub_rate); | ||
|
||
node_handle.getParam("benchmark_duration", benchmark_duration); | ||
|
||
// Create simulation manager object | ||
simulation_manager = new flatland_server::SimulationManager( | ||
world_path, update_rate, step_size, show_viz, viz_pub_rate); | ||
|
||
// Register sigint shutdown handler | ||
signal(SIGINT, SigintHandler); | ||
|
||
// timeout | ||
ros::WallTimer timeout_timer = node_handle.createWallTimer(ros::WallDuration(0.01), &CheckTimeout); | ||
|
||
ROS_INFO_STREAM_NAMED("Benchmark", "Initialized"); | ||
benchmark_start = ros::WallTime::now().toSec(); | ||
simulation_manager->Main(/*benchmark=*/true); | ||
|
||
ROS_INFO_STREAM_NAMED("Benchmark", "Returned from simulation manager main"); | ||
delete simulation_manager; | ||
simulation_manager = nullptr; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.