Skip to content

[PI Sprint 24/25 / PD-456] - [Feature] Implement Localization - #34

Open
mbsaloka wants to merge 45 commits into
masterfrom
feature/implement-localization
Open

[PI Sprint 24/25 / PD-456] - [Feature] Implement Localization#34
mbsaloka wants to merge 45 commits into
masterfrom
feature/implement-localization

Conversation

@mbsaloka

@mbsaloka mbsaloka commented Jan 7, 2025

Copy link
Copy Markdown
Member

Jira Link:

https://ichiro-its.atlassian.net/browse/PD-456?atlOrigin=eyJpIjoiYTNmODg5MjBmNGY0NDQ5NWIzOTQwNTVmMGM3YTkwZDAiLCJwIjoiaiJ9

Description

Implementing MCL algorithm in robot class

Type of Change

  • Bugfix
  • Enhancement
  • New feature
  • Breaking change (fix or feature that would cause the existing functionality to not work as expected)

How Has This Been Tested?

  • New unit tests added.
  • Manual tested.

Checklist:

  • Using Branch Name Convention
    • feature/JIRA-ID-SHORT-DESCRIPTION if has a JIRA ticket
    • enhancement/SHORT-DESCRIPTION if has/has no JIRA ticket and contain enhancement
    • hotfix/SHORT-DESCRIPTION if the change doesn't need to be tested (urgent)
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made the documentation for the corresponding changes.

Comment thread include/suiryoku/locomotion/model/field.hpp
Comment thread include/suiryoku/locomotion/model/field.hpp Outdated
Comment thread src/suiryoku/locomotion/model/robot.cpp Outdated
Comment thread src/suiryoku/locomotion/model/robot.cpp Outdated
Comment thread src/suiryoku/locomotion/model/robot.cpp Outdated
@mbsaloka mbsaloka changed the title [WIP] [Feature] Implement Localization [WIP] [PI Sprint 24/25] [Feature] Implement Localization Jan 11, 2025
@mbsaloka mbsaloka changed the title [WIP] [PI Sprint 24/25] [Feature] Implement Localization [WIP] [PI Sprint 24/25 / PD-456] [Feature] Implement Localization Jan 11, 2025
@mbsaloka mbsaloka changed the title [WIP] [PI Sprint 24/25 / PD-456] [Feature] Implement Localization [WIP] [PI Sprint 24/25 / PD-456] - [Feature] Implement Localization Jan 11, 2025
@mbsaloka mbsaloka changed the title [WIP] [PI Sprint 24/25 / PD-456] - [Feature] Implement Localization [PI Sprint 24/25 / PD-456] - [Feature] Implement Localization Jan 18, 2025
Comment thread src/suiryoku/locomotion/model/robot.cpp Outdated
Comment on lines +82 to +88
for (int i = 0; i < num_particles; ++i) {
Particle new_particle;
new_particle.position = keisan::Point2(xrg(xrd), yrg(yrd));
new_particle.orientation = orientation;
new_particle.weight = 1.0 / num_particles;

particles.push_back(new_particle);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor improvement, you can resize the particles size first instead of push_back to reduce memory reallocations.

Suggested change
for (int i = 0; i < num_particles; ++i) {
Particle new_particle;
new_particle.position = keisan::Point2(xrg(xrd), yrg(yrd));
new_particle.orientation = orientation;
new_particle.weight = 1.0 / num_particles;
particles.push_back(new_particle);
particles.resize(num_particles);
for (int i = 0; i < num_particles; ++i) {
Particle new_particle;
new_particle.position = keisan::Point2(xrg(xrd), yrg(yrd));
new_particle.orientation = orientation;
new_particle.weight = 1.0 / num_particles;
particles[i] = new_particle;

Check other loop that can be improved this way also.

Comment thread src/suiryoku/locomotion/model/robot.cpp Outdated
Comment on lines +217 to +218
x_rot = dx * cos(particle.orientation.radian()) - dy * sin(particle.orientation.radian());
y_rot = dx * sin(particle.orientation.radian()) + dy * cos(particle.orientation.radian());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
x_rot = dx * cos(particle.orientation.radian()) - dy * sin(particle.orientation.radian());
y_rot = dx * sin(particle.orientation.radian()) + dy * cos(particle.orientation.radian());
x_rot = dx * particle.orientation.cos() - dy * particle.orientation.sin()
y_rot = dx * particle.orientation.sin() + dy * particle.orientation.cos()

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