-
Notifications
You must be signed in to change notification settings - Fork 0
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
Regarding Visualization #59
Comments
I guess you are not happy with the below lines: I think you can make a struct struct DefaultVisualization {
visualization_msgs:msg::Marker primtive_line_strip;
}
And initialize the |
Also, I found another matters (not matter actually) on coding convention: avoid indentation as best as possible. For example: Your current version: TargetBestPathVisualizationMsg visual_output;
if (parameters_.target.best.publish) {
bool is_best_indices_generated = not best_indices.empty();
bool is_primitive_generated_big = not primitive_list.empty();
bool is_primitive_generated = true;
if (is_primitive_generated_big) {
for (int i = 0; i < primitive_list.size(); i++) {
if (primitive_list[i].empty())
is_primitive_generated = false;
}
}
is_primitive_generated = is_primitive_generated and is_primitive_generated_big;
if (is_best_indices_generated and is_primitive_generated) {
static vector<int> last_num_id;
visualization_msgs::msg::Marker line_strip;
line_strip.type = visualization_msgs::msg::Marker::LINE_STRIP;
line_strip.header.frame_id = parameters_.frame_id;
line_strip.color.a = parameters_.target.best.color.a;
line_strip.color.r = parameters_.target.best.color.r;
line_strip.color.g = parameters_.target.best.color.g;
line_strip.color.b = parameters_.target.best.color.b;
line_strip.scale.x = parameters_.target.best.line_scale;
line_strip.action = visualization_msgs::msg::Marker::MODIFY;
line_strip.pose.orientation.w = 1.0;
vector<float> time_seq;
float seg_t0 = primitive_list[0][best_indices[0]].px.GetTimeInterval()[0];
float seg_tf = primitive_list[0][best_indices[0]].px.GetTimeInterval()[1];
for (int i = 0; i < parameters_.target.best.num_time_sample; i++)
time_seq.push_back(seg_t0 + (float)i * (seg_tf - seg_t0) /
(float)(parameters_.target.best.num_time_sample - 1));
geometry_msgs::msg::Point temp_point;
for (int i = 0; i < best_indices.size(); i++) {
line_strip.points.clear();
line_strip.id = 0;
line_strip.ns = std::to_string(i) + "-th best_target_prediction";
for (int j = 0; j < parameters_.target.best.num_time_sample; j++) {
temp_point.x = primitive_list[i][best_indices[i]].px.GetValue(time_seq[j]);
temp_point.y = primitive_list[i][best_indices[i]].py.GetValue(time_seq[j]);
temp_point.z = primitive_list[i][best_indices[i]].pz.GetValue(time_seq[j]);
line_strip.points.push_back(temp_point);
}
visual_output.markers.push_back(line_strip);
}
}
} My recommendation: TargetBestPathVisualizationMsg visual_output;
if (not parameters_.target.best.publish)
return visual_output;
bool is_best_indices_generated = not best_indices.empty();
bool is_primitive_generated_big = not primitive_list.empty();
bool is_primitive_generated = true;
if (is_primitive_generated_big) {
for (int i = 0; i < primitive_list.size(); i++) {
if (primitive_list[i].empty())
is_primitive_generated = false;
}
}
is_primitive_generated = is_primitive_generated and is_primitive_generated_big;
if (!is_best_indices_generated || ! is_primitive_generated)
return visual_output;
static vector<int> last_num_id;
visualization_msgs::msg::Marker line_strip;
line_strip.type = visualization_msgs::msg::Marker::LINE_STRIP;
line_strip.header.frame_id = parameters_.frame_id;
line_strip.color.a = parameters_.target.best.color.a;
line_strip.color.r = parameters_.target.best.color.r;
line_strip.color.g = parameters_.target.best.color.g;
line_strip.color.b = parameters_.target.best.color.b;
line_strip.scale.x = parameters_.target.best.line_scale;
line_strip.action = visualization_msgs::msg::Marker::MODIFY;
line_strip.pose.orientation.w = 1.0;
vector<float> time_seq;
float seg_t0 = primitive_list[0][best_indices[0]].px.GetTimeInterval()[0];
float seg_tf = primitive_list[0][best_indices[0]].px.GetTimeInterval()[1];
for (int i = 0; i < parameters_.target.best.num_time_sample; i++)
time_seq.push_back(seg_t0 + (float)i * (seg_tf - seg_t0) /
(float)(parameters_.target.best.num_time_sample - 1));
geometry_msgs::msg::Point temp_point;
for (int i = 0; i < best_indices.size(); i++) {
line_strip.points.clear();
line_strip.id = 0;
line_strip.ns = std::to_string(i) + "-th best_target_prediction";
for (int j = 0; j < parameters_.target.best.num_time_sample; j++) {
temp_point.x = primitive_list[i][best_indices[i]].px.GetValue(time_seq[j]);
temp_point.y = primitive_list[i][best_indices[i]].py.GetValue(time_seq[j]);
temp_point.z = primitive_list[i][best_indices[i]].pz.GetValue(time_seq[j]);
line_strip.points.push_back(temp_point);
}
visual_output.markers.push_back(line_strip);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/LARR-Planning/los-keeper/blob/da48a7de85a9457144061aba505349f8704cc20f/los_keeper_ros2/src/visualization/visualizer.cc#L51-L97C1
Is there any way to make this part neater?
Every time I visualize primitives, I have to specify the specifications of markers like this. Doesn't code look messy?
The text was updated successfully, but these errors were encountered: