Skip to content
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

Added array parameters #37

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

leolander
Copy link

Array parameters are built into the standard get/set algorithm. The parameters are displayed in table form. The indexes of the array elements are displayed. There is support for horizontal table scrolling.The parameter is sent if any table element was edited and after that another table element was not selected. Therefore it is possible to change multiple elements in an array in one send. Table cell width automatically resizes based on text length.
rig_reconfigure demo video.zip

Copy link
Member

@ottojo ottojo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thank you for your contribution, array parameters are one of the big missing features in this tool. Thanks for being patient with us while waiting for a review.

I looked at your video, the functionality looks good, although the column with for double[]_param seems to not match the others, perhaps that can be fixed.

Not sending partial array updates also sounds useful, i think that would be expected behavior. Note to self and @authaldo : we should really look into some visual indication of node-state and display-state to make that even more obvious to the user, i think we brainstormed methods for this before but didnt come to a nice conclusion...

I did leave some notes on the implementation, i think keeping UI state well contained is important to keep the code modular and readable, and i would welcome suggestions by @authaldo .
The table generation seems a bit repetitive, but if it isn't easy to extract common functionality in a function, keep it that way.
The code style doesn't quite match the existing style, but since we don't have any .clang-format file yet (should be the clion defaults), i dont think thats important. Please do clean up redundant parentheses in a bunch of places though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the vscode config files, maybe add .vscode to the gitignore, since it contains user-specific file paths and settings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those are some forgotten notes from testing, please remove this file as well

Comment on lines +22 to +25
struct BoolArrayParam : ArrayParam<bool> {};
struct IntArrayParam : ArrayParam<long int> {};
struct DoubleArrayParam : ArrayParam<double> {};
struct StringArrayParam : ArrayParam<std::string> {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing the byte-array parameter type. i'm ok with intentionally omitting this in the assumption that it was designed for BLOBs, but we should note that here in that case

Comment on lines +18 to +19
bool isChanging;
bool isChanged;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to look into the code again to refresh my memory on how ROSParameterVariant is used, but combining the parameter value with additional state here seems unintuitive, maybe @authaldo has opinions on that

@@ -155,10 +155,13 @@ std::set<ImGuiID> visualizeParameters(ServiceWrapper &serviceWrapper,

ImGui::SameLine();
ImGui::PushItemWidth(static_cast<float>(textfieldWidth));
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_NoHostExtendX;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is a constant? if so, please make it constexpr and put it next to the other constants at the start of this file. if this is mutable, we should find a better place than a static variable deep inside this function

@@ -199,7 +202,150 @@ std::set<ImGuiID> visualizeParameters(ServiceWrapper &serviceWrapper,
serviceWrapper.pushRequest(
std::make_shared<ParameterModificationRequest>(ROSParameter(fullPath, value)));
}
}
} else if (std::holds_alternative<BoolArrayParam>(value)) {
if (ImGui::BeginTable(identifier.c_str(), (std::get<BoolArrayParam>(value)).arrayValue.size(), flags, outer_size))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (ImGui::BeginTable(identifier.c_str(), (std::get<BoolArrayParam>(value)).arrayValue.size(), flags, outer_size))
if (ImGui::BeginTable(identifier.c_str(), std::get<BoolArrayParam>(value).arrayValue.size(), flags, outer_size))

ImGui::TableNextColumn();
ImGui::PushID(cell);
ImGui::SetNextItemWidth(-FLT_MIN);
ImGui::DragScalar(identifier.c_str(), ImGuiDataType_S64, &((std::get<IntArrayParam>(value)).arrayValue.at(cell)), -1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above we use DragInt instead of DragScalar for integers, i don't know what the difference is but we should probably keep that consistent

Comment on lines +293 to +297
BoolArrayParam arrParam;
arrParam.isChanging = false;
arrParam.isChanged = false;
arrParam.arrayValue = valueMsg.bool_array_value;
ROSParameterVariant v = arrParam;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we keep the state and value combined in the parameter type, we should at least give *ArrayParam a constructor which initializes isChanging and isChanged to false, to avoid having to repeat that multiple times here. But i'm still not convinced of keeping (UI) state here...

@@ -11,6 +11,7 @@
#include "service_wrapper.hpp"
#include <chrono>
#include <regex>
#include <typeinfo>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is unused

Suggested change
#include <typeinfo>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants