Skip to content

Commit

Permalink
addressed reviewer feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Jenn Nguyen <[email protected]>
  • Loading branch information
jennuine committed Apr 12, 2022
1 parent c1067ba commit 855cb1d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 2 additions & 3 deletions include/sdf/Param.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ namespace sdf
{
const T &val;
const int precision; // Used to set std::ostream's std::setprecision
explicit ParamStreamer(const T &_val, int _precision = 0)
: val(_val), precision(_precision) {}
};

template<class T> ParamStreamer(T) -> ParamStreamer<T>;
template<class T> ParamStreamer(T, bool) -> ParamStreamer<T>;

template<class T>
std::ostream& operator<<(std::ostream &os, ParamStreamer<T> s)
{
Expand Down
7 changes: 4 additions & 3 deletions src/cmd/cmdsdformat.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ COMMANDS = { 'sdf' =>
" -d [ --describe ] [SPEC VERSION] Print the aggregated SDFormat spec description. Default version (@SDF_PROTOCOL_VERSION@).\n" +
" -g [ --graph ] <pose, frame> arg Print the PoseRelativeTo or FrameAttachedTo graph. (WARNING: This is for advanced\n" +
" use only and the output may change without any promise of stability)\n" +
" -p [ --print ] arg Print converted arg. Note poses and unit vectors will be normalized.\n" +
" -p [ --print ] arg Print converted arg. Note the quaternion representation of the\n" +
" rotational part of poses and unit vectors will be normalized.\n" +
" -i [ --preserve-includes ] Preserve included tags when printing converted arg (does not preserve merge-includes).\n" +
" --degrees Pose rotation angles are printed in degrees.\n" +
" --snap-to-degrees arg Snap pose rotation angles to this specified interval in degrees. This value must be\n" +
" larger than 0, less than or equal to 360, and larger than the defined snap tolerance.\n" +
" --snap-tolerance arg Used in conjunction with --snap-to-degrees, specifies the tolerance at which snapping\n" +
" occurs. This value must be larger than 0, less than 360, and less than the defined\n" +
" degrees value to snap to. If unspecified, its default value is 0.01.\n" +
" --precision arg Set the output stream precision for floating point numbers. The arg must be an integer.\n" +
" --precision arg Set the output stream precision for floating point numbers. The arg must be a positive integer.\n" +

COMMON_OPTIONS
}
Expand Down Expand Up @@ -214,7 +215,7 @@ class Cmd
exit(Importer.cmdDescribe(options['describe']))
elsif options.key?('print')
snap_to_degrees = 0
precision = -9999
precision = 0

if options.key?('snap_to_degrees')
if options['snap_to_degrees'] < options['snap_tolerance']
Expand Down
7 changes: 4 additions & 3 deletions src/ign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ extern "C" SDFORMAT_VISIBLE int cmdDescribe(const char *_version)
//////////////////////////////////////////////////
extern "C" SDFORMAT_VISIBLE int cmdPrint(const char *_path,
int _inDegrees, int _snapToDegrees, float _snapTolerance,
bool _preserveIncludes, int _outPrecision)
int _preserveIncludes, int _outPrecision)
{
if (!sdf::filesystem::exists(_path))
{
Expand Down Expand Up @@ -169,9 +169,10 @@ extern "C" SDFORMAT_VISIBLE int cmdPrint(const char *_path,
static_cast<double>(_snapTolerance));
}

config.SetPreserveIncludes(_preserveIncludes);
if (_preserveIncludes != 0)
config.SetPreserveIncludes(true);

if (_outPrecision != -9999)
if (_outPrecision > 0)
config.SetOutPrecision(_outPrecision);

sdf->PrintValues(config);
Expand Down

0 comments on commit 855cb1d

Please sign in to comment.