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

Obstacle Layer Port #318

Merged
merged 9 commits into from
Nov 14, 2018
Merged

Obstacle Layer Port #318

merged 9 commits into from
Nov 14, 2018

Conversation

bpwilcox
Copy link


Basic Info

Info Please fill out this column
Ticket(s) this addresses #192
Primary OS tested on Ubuntu 16.04
Primary platform tested on NUC

Description of contribution in a few bullet points

  • port of obstacle layer

Future work that may be required in bullet points


@bpwilcox bpwilcox added enhancement New feature or request costmap_2d 0 - Critical Critical to project, highest priority labels Nov 13, 2018
@bpwilcox bpwilcox added this to the November 2018 milestone Nov 13, 2018
@SteveMacenski
Copy link
Member

@bpwilcox please squash my commits - the naming of at least cough the first one isn't ideal.


if (!(data_type == "PointCloud2" || data_type == "PointCloud" || data_type == "LaserScan")) {
ROS_FATAL("Only topics that use point clouds or laser scans are currently supported");
node_->get_parameter_or<std::string>("topic", topic, source);
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 in the stream of inputs from configuring multiple sensor inputs (or types if some are to only clear or mark). I dont see here where node_ or source are updated to go up and down into new sensor namespaces to get the parameters. Maybe I'm missing something.

Copy link
Author

Choose a reason for hiding this comment

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

I think you are right, I overlooked the updated namespace of the parameters, however since only one node is being spun here, the parameters must exist on this node (or some other node also being spun for which we can create a client). I can add a prefix to the param names which will effectively do the same, though they will all live on the costmap node. This should be fine since yaml files support prefix namespaces on parameters. The only other solution I think would be to create (and spin) separate nodes for each source, which I don't believe we want to do.

Copy link
Member

@SteveMacenski SteveMacenski Nov 13, 2018

Choose a reason for hiding this comment

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

Yeah, that would be not good. The reason to have multiple sensors in the same node is so different sensors can clear out each other as the robot moves relative to obstacles (or obstacles themselves move). It's a pretty important feature that you can configure multiple marking/clearing sources in each layer.

The parameters would still exist in this node, however there's mulitiple sources that represents (hence why there's a subscriber vector) See a simple example here of multiple sensors. I can't share our internal ones, but suffice to say that any robot with > 1 sensor uses this

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I understand the use case as you describe. I plan to update to prefix a parameter namespace as the source for the sensor.

"Created an observation buffer for source %s, topic %s, global frame: %s, "
"expected update rate: %.2f, observation persistence: %.2f",
source.c_str(), topic.c_str(),
global_frame_.c_str(), expected_update_rate, observation_keep_time);

rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_default;
custom_qos_profile.depth = 50;
Copy link
Member

Choose a reason for hiding this comment

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

Is this generally needed at 50? Should it be parameterized?

Copy link
Author

Choose a reason for hiding this comment

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

50 was the depth in the message filter code in the original, but it could also be a parameter per source I suppose.

@bpwilcox bpwilcox force-pushed the port_obstacle branch 5 times, most recently from 98136ca to ddfb26e Compare November 14, 2018 07:58
@bpwilcox bpwilcox mentioned this pull request Nov 14, 2018
node_->set_parameter_if_not_set("inflation_radius", 0.55);
node_->set_parameter_if_not_set("cost_scaling_factor", 10.0);
node_->set_parameter_if_not_set("inflate_unknown",false);
node_->set_parameter_if_not_set(name_ + "." + "enabled",true);

Choose a reason for hiding this comment

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

Why not merge the dots into the next strings? Makes it a bit easier to read (fewer elements to concatenate).

Copy link
Author

Choose a reason for hiding this comment

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

I actually found it more convenient to copy and paste the concatenation than to manually insert the dot into every parameter (goal being to leave parameter name string untouched). I'd prefer to merge the first two strings, if anything.

Copy link

Choose a reason for hiding this comment

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

You could've done what @mjeronimo suggested by using search and replace in your editor
eg.
search for set_parameter_if_not_set("
and replace with set_parameter_if_not_set(name_ + ".

Copy link
Author

Choose a reason for hiding this comment

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

Good point. Still, I made a comment in the voxel layer PR that I'm not a fan of altering the base parameter name for clarity as well as the cases where it is a variable.

//std::vector<std::shared_ptr<message_filters::SubscriberBase> > observation_subscribers_; ///< @brief Used for the observation message filters
//std::vector<std::shared_ptr<tf2_ros::MessageFilterBase> > observation_notifiers_; ///< @brief Used to make sure that transforms are available for each sensor

std::vector<rclcpp::Subscription<sensor_msgs::msg::LaserScan>::ConstSharedPtr> observation_laser_subscribers_;

Choose a reason for hiding this comment

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

A comment or two about the usage of these members.

SteveMacenski and others added 8 commits November 14, 2018 12:02
base include in CMakaeLists and first stab port of obstacle layer

continued porting obstacle layer changes

resolving everything for next person except stringstream + message filters issues

add back current amcl changes

add back current dockerfile changes
node_->set_parameter_if_not_set("inflation_radius", 0.55);
node_->set_parameter_if_not_set("cost_scaling_factor", 10.0);
node_->set_parameter_if_not_set("inflate_unknown",false);
node_->set_parameter_if_not_set(name_ + "." + "enabled",true);
Copy link

Choose a reason for hiding this comment

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

You could've done what @mjeronimo suggested by using search and replace in your editor
eg.
search for set_parameter_if_not_set("
and replace with set_parameter_if_not_set(name_ + ".


node_->get_parameter_or<std::string>(source + "." + "topic", topic, source);
node_->get_parameter_or<std::string>(source + "." + "sensor_frame", sensor_frame, std::string(""));
node_->get_parameter_or<double>(source + "." + "observation_persistence", observation_keep_time, 0.0);
Copy link

Choose a reason for hiding this comment

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

Do you really need the type specifiers here (<double>)? I thought that it was automatically deduced from the variable's type.

Copy link
Author

Choose a reason for hiding this comment

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

I can probably remove the specifier

// TODO(bpwilcox): replace with message filters above when enabled
// create a callback for the topic
auto buffer = observation_buffers_.back();
if (data_type == "LaserScan") {
Copy link

Choose a reason for hiding this comment

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

There's a lot of redundancy in this code block. I realize it is temporary code and should go away when message filters is enabled, but who knows how long temporary is. I'll leave it up to you whether you want to fix it or leave it alone such that your name comes up when somebody runs git blame ;-)

Copy link
Author

Choose a reason for hiding this comment

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

The message filters code is equally redundant, my format is pretty much the same. I'm ok leaving as is for now.

Copy link

Choose a reason for hiding this comment

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

Ok. For future reference, I think what I'd have done here is just define a macro at the start of the function and then used that to simplify the subscription creation code.

#define CREATE_SUBSCRIBER(message_type, callback) \
  node_->create_subscription<message_type>(topic, [&, buffer] (message_type::ConstSharedPtr message) \ 
          { callback(message, buffer); }, custom_qos_profile);

...
if (data_type == "LaserScan") {
  if (inf_is_valid) {
   sub = CREATE_SUBSCRIBER(sensor_msgs::msg::LaserScan, laserScanValidInfCallback);
  } else {
    sub = CREATE_SUBSCRIBER(sensor_msgs::msg::LaserScan, laserScanValidCallback);
  }
} else {
  if (inf_is_valid) {
   RCLCPP_WARN ...
  } else {
    sub = CREATE_SUBSCRIBER(sensor_msgs::msg::PointCloud2, pointCloud2Callback);
  }
}

@bpwilcox bpwilcox merged commit 0215a75 into ros-navigation:master Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - Critical Critical to project, highest priority costmap_2d enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants