-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default value initialization to avoid redundant variable assignment #678
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b6271a2
update order of wavefield parameters message
tejalbarnwal d56e6fe
added wavefield parameters to practice_2023_worlds_follow_path sdf files
tejalbarnwal 56a0909
added default values for unneeded variables
tejalbarnwal f42a243
updated sydney_regatta world file
tejalbarnwal 17aa66e
Merge branch 'main' into tejal/avoid_unneeded_variable
caguero bfc3884
Merge branch 'main' into tejal/avoid_unneeded_variable
M1chaelM 47044e9
Merge branch 'main' into tejal/avoid_unneeded_variable
M1chaelM feedd84
removed unneeded variables from sdf world files
tejalbarnwal 9a8185c
updated difficult practice worlds with gain 2 and period 2
tejalbarnwal 7605e2f
removed debug print statement
tejalbarnwal e022061
updated default values inside header file
tejalbarnwal 53fc266
Merge branch 'main' into tejal/avoid_unneeded_variable
M1chaelM 9909ea3
refactored with minor formatting adjustments
tejalbarnwal f78da3b
updated the steepness to its original value
tejalbarnwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ | |
#include <gz/math/Vector2.hh> | ||
#include <gz/math/Vector3.hh> | ||
|
||
#include <iostream> | ||
|
||
#include "Wavefield.hh" | ||
|
||
using namespace gz; | ||
|
@@ -48,21 +50,21 @@ class vrx::WavefieldPrivate | |
{ | ||
/// \brief Constructor. | ||
public: WavefieldPrivate(): | ||
size({1000, 1000}), | ||
cellCount({50, 50}), | ||
size({6000, 6000}), | ||
cellCount({300, 300}), | ||
model("PMS"), | ||
number(1), | ||
scale(2), | ||
angle(2.0*M_PI/10.0), | ||
steepness(1.0), | ||
number(3), | ||
scale(1.1), | ||
angle(0.4), | ||
steepness(0.0), | ||
amplitude(0.0), | ||
period(1.0), | ||
period(5.0), | ||
phase(0.0), | ||
direction(1, 0), | ||
angularFrequency(2.0*M_PI), | ||
wavelength(2 * M_PI / this->DeepWaterDispersionToWavenumber(2.0 * M_PI)), | ||
wavenumber(this->DeepWaterDispersionToWavenumber(2.0 * M_PI)), | ||
tau(1.0), | ||
tau(2.0), | ||
gain(1.0) | ||
{ | ||
} | ||
|
@@ -469,22 +471,48 @@ void Wavefield::Load(const msgs::Param &_msg) | |
{ | ||
auto params = _msg.params(); | ||
|
||
this->data->size = {params["size"].vector3d_value().x(), | ||
params["size"].vector3d_value().y()}; | ||
this->data->cellCount = {params["cell_count"].vector3d_value().x(), | ||
params["cell_count"].vector3d_value().y()}; | ||
this->data->number = params["number"].int_value(); | ||
this->data->scale = params["scale"].double_value(); | ||
this->data->angle = params["angle"].double_value(); | ||
this->data->steepness = params["steepness"].double_value(); | ||
this->data->amplitude = params["amplitude"].double_value(); | ||
this->data->period = params["period"].double_value(); | ||
this->data->phase = params["phase"].double_value(); | ||
this->data->direction = {params["direction"].vector3d_value().x(), | ||
params["direction"].vector3d_value().y()}; | ||
this->data->model = params["model"].string_value(); | ||
this->data->gain = params["gain"].double_value(); | ||
this->data->tau = params["tau"].double_value(); | ||
if (params.count("size") > 0){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: Could you move the open bracket to the next line to be consistent with the Gazebo style?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, i will update them |
||
this->data->size = {params["size"].vector3d_value().x(), | ||
params["size"].vector3d_value().y()}; | ||
} | ||
if (params.count("cell_count") > 0){ | ||
this->data->cellCount = {params["cell_count"].vector3d_value().x(), | ||
params["cell_count"].vector3d_value().y()}; | ||
} | ||
if (params.count("number") > 0){ | ||
this->data->number = params["number"].int_value(); | ||
} | ||
if (params.count("scale") > 0){ | ||
this->data->scale = params["scale"].double_value(); | ||
} | ||
if (params.count("angle") > 0){ | ||
this->data->angle = params["angle"].double_value(); | ||
} | ||
if (params.count("steepness") > 0){ | ||
this->data->steepness = params["steepness"].double_value(); | ||
} | ||
if (params.count("amplitude") > 0){ | ||
this->data->amplitude = params["amplitude"].double_value(); | ||
} | ||
if (params.count("period") > 0){ | ||
this->data->period = params["period"].double_value(); | ||
} | ||
if (params.count("phase") > 0){ | ||
this->data->phase = params["phase"].double_value(); | ||
} | ||
if (params.count("direction") > 0){ | ||
this->data->direction = {params["direction"].vector3d_value().x(), | ||
params["direction"].vector3d_value().y()}; | ||
} | ||
if (params.count("model") > 0){ | ||
this->data->model = params["model"].string_value(); | ||
} | ||
if (params.count("gain") > 0){ | ||
this->data->gain = params["gain"].double_value(); | ||
} | ||
if (params.count("tau") > 0){ | ||
this->data->tau = params["tau"].double_value(); | ||
} | ||
|
||
this->data->FillParameters(); | ||
this->data->Recalculate(); | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this
#include
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I forgot to remove that
I used it to debug initially, will remove it