question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

robot-name: collision detection not convincing

See original GitHub issue

differentRobotsHaveDifferentNames and resetName are not proper tests for detecting collisions. They need many more iterations to be convincing (~1/670000).

Here is my modified test:

import org.junit.Test;

import java.util.stream.IntStream;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;

public class RobotTest {

    private static final String EXPECTED_ROBOT_NAME_PATTERN = "\\w{2}\\d{3}";
    private final Robot robot1 = new Robot();
    private final Robot robot2 = new Robot();

    @Test
    public void hasName() {
        assertIsValidName(robot1.getName());
    }

    @Test
    public void differentRobotsHaveDifferentNames() {
        IntStream.range(0, 300000).forEach(x -> {
            assertThat(robot1.getName(), not(equalTo(new Robot().getName())));
        });
    }

    @Test
    public void resetName() {
        IntStream.range(0, 300000).forEach(x -> {
            final String name = robot2.getName();
            robot2.reset();
            final String name2 = robot2.getName();
            assertThat(name, not(equalTo(name2)));
            assertIsValidName(name2);
        });
    }

    private static void assertIsValidName(String name) {
        assertThat(name.matches(EXPECTED_ROBOT_NAME_PATTERN), is(true));
    }
}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
stkentcommented, Jun 12, 2017

I have a feeling that the specification of this exercise disallows convincing tests. There’s no canonical test data. If anyone is interested in picking this up in the future I’d recommend starting by reviewing the tests in other tracks to see if this conundrum has already been worked around someplace else.

0reactions
stkentcommented, Aug 16, 2017

Closing until there’s interest in actively working on this again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Collision detection not working unity - Stack Overflow
The physics Layer Collision Matrix is set to not detect collision between the layers the objects are (enter Edit > Project > Phisics...
Read more >
Self-collision avoidance — NAO Software 1.14.5 documentation
Collision detection and avoidance only works for Joint methods but not for Cartesian and Whole body methods. It also works when making the...
Read more >
Unexpected behaviour of checkCollision for robot collision ...
I want to use the function with no or very small z-offset in order to do a realistic collision detection. Is this just...
Read more >
Advanced Collision Detection — NVIDIA PhysX SDK 3.4.0 ...
Then next frame, the SDK's contact generation takes over and generates a convincing motion. There are some subtle details not described here, but...
Read more >
Collision detection - Coppelia Robotics
CoppeliaSim can detect collisions between two collidable entities in a flexible way. The calculation is an exact interference calculation. Collision detection, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found