Skip to content

Commit

Permalink
More clear output to test against detection logs
Browse files Browse the repository at this point in the history
jhirsh
  • Loading branch information
Jonas Hirshland authored and dziedada committed Dec 8, 2019
1 parent 616551e commit a7810aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ thirdparty/Qt5
qt-*
scripts/install
armlab-regular/env/
*.jlp
11 changes: 6 additions & 5 deletions include/planner/arm_planner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ArmPlanner
for (size_t i = 0; i < newBalls.detections.size(); ++i)
{
ball_detection_t detection = newBalls.detections[i];
Eigen::Vector2d ballPosition( detection.position[0], detection.position[1] );
Eigen::Vector2d detectionPosition( detection.position[0], detection.position[1] );

Ball * closest;
double closestDistance = DBL_MAX;
Expand All @@ -115,12 +115,12 @@ class ArmPlanner

Eigen::Vector4d predictionState = ball.predict_coordinate( detection.utime );
Eigen::Vector2d prediction( predictionState.x(), predictionState.y() );
double distance = (prediction - ballPosition).norm();
std::cout << "Ball " << ballPosition.x() << " " << ballPosition.y() << std::endl;
std::cout << "Prediction " << prediction.x() << " " << prediction.y() << std::endl;
std::cout << "Distance " << distance;
double distance = (prediction - detectionPosition).norm();
if ( distance < corrThreshold && distance < closestDistance )
{
std::cout << "Detection " << detectionPosition.x() << " " << detectionPosition.y() << std::endl;
//std::cout << "Prediction " << prediction.x() << " " << prediction.y() << std::endl;
std::cout << "Distance " << distance << std::endl;
closest = &ball;
closestDistance = distance;
}
Expand All @@ -144,6 +144,7 @@ class ArmPlanner
if ( (*it).odds < -10 )
{
// purge ball
std::cout << "Purged ball... " << balls.size() << " left";
it = balls.erase( it );
}
else
Expand Down
6 changes: 5 additions & 1 deletion src/planner/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ class Handler

planner->updateBalls( *ball );

if(planner->balls.empty()) return;
std::vector<Vector2d> plan = planner->calculatePlan( );
/*
auto pos = planner->balls[0].getPos();
cout << pos << '\n';
cout << " calculated Plan at " << endl;
//planner.publishPlan( plan );
planner.publishPlan( plan );
*/
}

private:
shared_ptr<ArmPlanner> planner;
int64_t prevTime = 0;
};

// Handles lcm in a loop until program no longer running
Expand Down

0 comments on commit a7810aa

Please sign in to comment.