-
Notifications
You must be signed in to change notification settings - Fork 13
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
Account for measurement delay in localization #650
Changes from 9 commits
a057ad0
29f2966
71e7eba
351593b
d6f837c
ee269de
bd731cd
3f8512e
f3a8e91
ab6daa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,7 @@ body_behavior: | |
dribble_ball_distance_threshold: 0.5 | ||
dribble_kick_angle: 0.6 | ||
|
||
kick_decision_smoothing: 5.0 | ||
kick_decision_smoothing: 1.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. While testing I noticed that this smoothing is not really needed anymore btw. 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. so remove this parameter alltogether later? |
||
|
||
################## | ||
# costmap params # | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,15 @@ | |
#define BITBOTS_LOCALIZATION_OBSERVATIONMODEL_H | ||
|
||
#include <particle_filter/ParticleFilter.h> | ||
#include <tf2_ros/buffer.h> | ||
|
||
#include <bitbots_localization/RobotState.hpp> | ||
#include <bitbots_localization/map.hpp> | ||
#include <bitbots_localization/tools.hpp> | ||
#include <sensor_msgs/msg/point_cloud2.hpp> | ||
#include <sensor_msgs/point_cloud2_iterator.hpp> | ||
#include <soccer_vision_3d_msgs/msg/field_boundary.hpp> | ||
#include <soccer_vision_3d_msgs/msg/goalpost.hpp> | ||
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. You removed the field boundary because it is not used anymore. As far as I know, goal posts arent used either, do you want to remove them too (also in the localization.cpp and so on). 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. The field boundary performs quite poorly in the localization and we might include the goalpost with a higher chance in the near future (although not planned). |
||
#include <soccer_vision_3d_msgs/msg/goalpost_array.hpp> | ||
#include <soccer_vision_3d_msgs/msg/marking_array.hpp> | ||
#include <soccer_vision_3d_msgs/msg/marking_intersection.hpp> | ||
|
||
#include "localization_parameters.hpp" | ||
|
||
|
@@ -31,8 +29,7 @@ class RobotPoseObservationModel : public particle_filter::ObservationModel<Robot | |
* empty | ||
*/ | ||
RobotPoseObservationModel(std::shared_ptr<Map> map_lines, std::shared_ptr<Map> map_goals, | ||
std::shared_ptr<Map> map_field_boundary, const bitbots_localization::Params &config, | ||
const FieldDimensions &field_dimensions); | ||
const bitbots_localization::Params &config, const FieldDimensions &field_dimensions); | ||
|
||
/** | ||
* | ||
|
@@ -45,36 +42,36 @@ class RobotPoseObservationModel : public particle_filter::ObservationModel<Robot | |
|
||
void set_measurement_goalposts(sv3dm::msg::GoalpostArray measurement); | ||
|
||
void set_measurement_field_boundary(sv3dm::msg::FieldBoundary measurement); | ||
const std::vector<std::pair<double, double>> get_measurement_lines() const; | ||
|
||
void set_measurement_markings(sv3dm::msg::MarkingArray measurement); | ||
|
||
std::vector<std::pair<double, double>> get_measurement_lines() const; | ||
|
||
std::vector<std::pair<double, double>> get_measurement_goals() const; | ||
|
||
std::vector<std::pair<double, double>> get_measurement_field_boundary() const; | ||
const std::vector<std::pair<double, double>> get_measurement_goals() const; | ||
|
||
double get_min_weight() const override; | ||
|
||
void clear_measurement(); | ||
|
||
bool measurements_available() override; | ||
|
||
void set_movement_since_line_measurement(const tf2::Transform movement); | ||
void set_movement_since_goal_measurement(const tf2::Transform movement); | ||
|
||
private: | ||
double calculate_weight_for_class(const RobotState &state, | ||
const std::vector<std::pair<double, double>> &last_measurement, | ||
std::shared_ptr<Map> map, double element_weight) const; | ||
std::shared_ptr<Map> map, double element_weight, | ||
const tf2::Transform &movement_since_measurement) const; | ||
|
||
// Measurements | ||
std::vector<std::pair<double, double>> last_measurement_lines_; | ||
std::vector<std::pair<double, double>> last_measurement_goal_; | ||
std::vector<std::pair<double, double>> last_measurement_field_boundary_; | ||
|
||
// Movement since last measurement | ||
tf2::Transform movement_since_line_measurement_ = tf2::Transform::getIdentity(); | ||
tf2::Transform movement_since_goal_measurement_ = tf2::Transform::getIdentity(); | ||
|
||
// Reference to the maps for the different classes | ||
std::shared_ptr<Map> map_lines_; | ||
std::shared_ptr<Map> map_goals_; | ||
std::shared_ptr<Map> map_field_boundary_; | ||
|
||
// Parameters | ||
bitbots_localization::Params config_; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,6 @@ | |
#include <rclcpp/rclcpp.hpp> | ||
#include <sensor_msgs/msg/camera_info.hpp> | ||
#include <sensor_msgs/msg/point_cloud2.hpp> | ||
#include <soccer_vision_3d_msgs/msg/field_boundary.hpp> | ||
#include <soccer_vision_3d_msgs/msg/goalpost_array.hpp> | ||
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. same here, are goalposts even needed? |
||
#include <std_msgs/msg/color_rgba.hpp> | ||
#include <std_srvs/srv/trigger.hpp> | ||
|
@@ -110,12 +109,6 @@ class Localization { | |
*/ | ||
void GoalPostsCallback(const sv3dm::msg::GoalpostArray &msg); // TODO | ||
|
||
/** | ||
* Callback for the relative field boundary measurements | ||
* @param msg Message containing the field boundary points. | ||
*/ | ||
void FieldboundaryCallback(const sv3dm::msg::FieldBoundary &msg); | ||
|
||
/** | ||
* Resets the state distribution of the state space | ||
* @param distribution The type of the distribution | ||
|
@@ -158,17 +151,13 @@ class Localization { | |
// Declare subscribers | ||
rclcpp::Subscription<sm::msg::PointCloud2>::SharedPtr line_point_cloud_subscriber_; | ||
rclcpp::Subscription<sv3dm::msg::GoalpostArray>::SharedPtr goal_subscriber_; | ||
rclcpp::Subscription<sv3dm::msg::FieldBoundary>::SharedPtr fieldboundary_subscriber_; | ||
|
||
rclcpp::Subscription<gm::msg::PoseWithCovarianceStamped>::SharedPtr rviz_initial_pose_subscriber_; | ||
|
||
// Declare publishers | ||
rclcpp::Publisher<gm::msg::PoseWithCovarianceStamped>::SharedPtr pose_with_covariance_publisher_; | ||
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr pose_particles_publisher_; | ||
rclcpp::Publisher<visualization_msgs::msg::Marker>::SharedPtr lines_publisher_; | ||
rclcpp::Publisher<visualization_msgs::msg::Marker>::SharedPtr line_ratings_publisher_; | ||
rclcpp::Publisher<visualization_msgs::msg::Marker>::SharedPtr goal_ratings_publisher_; | ||
rclcpp::Publisher<visualization_msgs::msg::Marker>::SharedPtr fieldboundary_ratings_publisher_; | ||
rclcpp::Publisher<nav_msgs::msg::OccupancyGrid>::SharedPtr field_publisher_; | ||
|
||
// Declare services | ||
|
@@ -179,8 +168,8 @@ class Localization { | |
rclcpp::TimerBase::SharedPtr publishing_timer_; | ||
|
||
// Declare tf2 objects | ||
std::unique_ptr<tf2_ros::Buffer> tfBuffer; | ||
std::shared_ptr<tf2_ros::TransformListener> tfListener; | ||
std::shared_ptr<tf2_ros::Buffer> tf_buffer_; | ||
std::shared_ptr<tf2_ros::TransformListener> tf_listener_; | ||
std::shared_ptr<tf2_ros::TransformBroadcaster> br; | ||
|
||
// Declare particle filter components | ||
|
@@ -201,7 +190,6 @@ class Localization { | |
// Declare input message buffers | ||
sm::msg::PointCloud2 line_pointcloud_relative_; | ||
sv3dm::msg::GoalpostArray goal_posts_relative_; | ||
sv3dm::msg::FieldBoundary fieldboundary_relative_; | ||
|
||
// Declare time stamps | ||
rclcpp::Time last_stamp_lines = rclcpp::Time(0); | ||
|
@@ -219,16 +207,12 @@ class Localization { | |
// Keep track of the odometry transform in the last step | ||
geometry_msgs::msg::TransformStamped previousOdomTransform_; | ||
|
||
// Flag that checks if the robot is moving | ||
bool robot_moved = false; | ||
|
||
// Keep track of the number of filter steps | ||
int timer_callback_count_ = 0; | ||
|
||
// Maps for the different measurement classes | ||
std::shared_ptr<Map> lines_; | ||
std::shared_ptr<Map> goals_; | ||
std::shared_ptr<Map> field_boundary_; | ||
|
||
// RNG that is used for the different sampling steps | ||
particle_filter::CRandomNumberGenerator random_number_generator_; | ||
|
@@ -271,8 +255,8 @@ class Localization { | |
* @param map map for this class | ||
* @param publisher ros publisher for the type visualization_msgs::msg::Marker | ||
*/ | ||
void publish_debug_rating(std::vector<std::pair<double, double>> measurements, double scale, const char name[24], | ||
std::shared_ptr<Map> map, | ||
void publish_debug_rating(const std::vector<std::pair<double, double>> &measurements, double scale, | ||
const char name[24], std::shared_ptr<Map> map, | ||
rclcpp::Publisher<visualization_msgs::msg::Marker>::SharedPtr &publisher); | ||
|
||
/** | ||
|
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.
What is smoothing close?
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.
It smooths the ball close decision.