Advertisement
Guest User

ia_codigo_media-particula

a guest
Jun 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. particle
  2. compute_average_state(std::vector<particle> *particle_set_t)
  3. {
  4. particle mean_particle;
  5. double total_weight = 0.0;
  6. double mean_x, mean_y, mean_theta_x, mean_theta_y, mean_velocity;
  7.  
  8. /* compute mean particle pose */
  9. mean_x = 0.0;
  10. mean_y = 0.0;
  11. mean_theta_x = 0.0;
  12. mean_theta_y = 0.0;
  13. mean_velocity = 0.0;
  14. for(std::vector<particle>::iterator it = particle_set_t->begin();
  15. it != particle_set_t->end(); it++)
  16. {
  17. mean_x += it->pose.x * it->weight;
  18. mean_y += it->pose.y * it->weight;
  19. mean_theta_x += cos(it->pose.theta) * it->weight;
  20. mean_theta_y += sin(it->pose.theta) * it->weight;
  21. mean_velocity += it->velocity * it->weight;
  22. total_weight += it->weight;
  23. }
  24.  
  25. mean_particle.pose.x = mean_x / total_weight;
  26. mean_particle.pose.y = mean_y / total_weight;
  27. mean_particle.pose.theta = carmen_normalize_theta(atan2(mean_theta_y, mean_theta_x));
  28. mean_particle.velocity = mean_velocity / total_weight;
  29. // mean_particle.velocity = mean_velocity;
  30.  
  31. return(mean_particle);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement