darwin_walk_toward_target
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
darwin_walk_toward_target [2017/11/19 17:57] – [Motivation and Audience] yuhanghe | darwin_walk_toward_target [2017/11/20 16:12] (current) – [Motivation and Audience] yuhanghe | ||
---|---|---|---|
Line 22: | Line 22: | ||
The rest of this tutorial is presented as follows: | The rest of this tutorial is presented as follows: | ||
- | * [[new_mode_demonstration# | + | * [[darwin_walk_toward_target# |
- | * [[new_mode_demonstration# | + | * [[darwin_walk_toward_target# |
- | * [[new_mode_demonstration# | + | * [[darwin_walk_toward_target# |
Line 60: | Line 60: | ||
} | } | ||
} | } | ||
- | | + | ////////////////////////////// |
+ | ///Skipping Unmodified Codes// | ||
+ | ////////////////////////////// | ||
// Line 267 Add | // Line 267 Add | ||
else if(m_cur_mode == SPRINT) | else if(m_cur_mode == SPRINT) | ||
Line 158: | Line 160: | ||
////////////////////////////// | ////////////////////////////// | ||
//Around Line 80 | //Around Line 80 | ||
+ | |||
ColorFinder* green_finder = new ColorFinder(120, | ColorFinder* green_finder = new ColorFinder(120, | ||
ColorFinder* blue_finder = new ColorFinder(225, | ColorFinder* blue_finder = new ColorFinder(225, | ||
Line 166: | Line 169: | ||
BallFollower marker_follower = BallFollower(); | BallFollower marker_follower = BallFollower(); | ||
//created a new BallFollower object to follow target/ | //created a new BallFollower object to follow target/ | ||
- | + | int _marker_found = 0; | |
+ | //created a flag for marker | ||
+ | ////////////////////////////// | ||
+ | ///Skipping Unmodified Codes// | ||
+ | ////////////////////////////// | ||
//inside while loop | //inside while loop | ||
while(1) { | while(1) { | ||
- | else if(StatusCheck:: | + | int greenCount |
- | | + | |
Point2D green, blue, center; | Point2D green, blue, center; | ||
//created 3 objects of Point2D class | //created 3 objects of Point2D class | ||
+ | |||
+ | else if(StatusCheck:: | ||
+ | { | ||
| | ||
- | green = green_finder-> | + | green = green_finder-> |
- | blue = blue_finder-> | + | //using the modified GetPosition function that also return filtered pixel counts |
+ | blue = blue_finder-> | ||
//store position of green and blue color | //store position of green and blue color | ||
| | ||
Line 189: | Line 200: | ||
//calculate center of blue and green | //calculate center of blue and green | ||
| | ||
- | marker_tracker.process(center); | + | |
- | //use camera tracking | + | //use camera tracking |
+ | | ||
} | } | ||
- | //L317 Add | + | |
+ | ///Skipping Unmodified Codes// | ||
+ | ////////////////////////////// | ||
+ | //around Line 350 Add | ||
case SPRINT: | case SPRINT: | ||
//implement new codes here to execute after pressing start button | //implement new codes here to execute after pressing start button | ||
+ | if(Action:: | ||
+ | { | ||
+ | Head:: | ||
+ | Walking:: | ||
+ | // | ||
+ | | ||
+ | if(Walking:: | ||
+ | Walking:: | ||
+ | //Set forward and back step length to 30cm | ||
+ | | ||
+ | Walking:: | ||
+ | //Set yaw step length to 0 | ||
+ | |||
+ | Walking:: | ||
+ | } | ||
+ | | ||
+ | if(_marker_found == 1) | ||
+ | { | ||
+ | marker_follower.Process(marker_tracker.ball_position); | ||
+ | //use BallFollower object to start following marker | ||
+ | | ||
+ | if(greenCount >= 10500 || blueCount >= 10500) | ||
+ | //pixel count can be used to approximate distance, but in this case, | ||
+ | //this stop condition is sufficient | ||
+ | { | ||
+ | Walking:: | ||
+ | fprintf(stderr, | ||
+ | while(Walking:: | ||
+ | } | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
</ | </ | ||
Line 205: | Line 256: | ||
===== Final Words ===== | ===== Final Words ===== | ||
- | This tutorial' | + | This tutorial' |
\\ | \\ | ||
\\ | \\ |
darwin_walk_toward_target.1511143067.txt.gz · Last modified: by yuhanghe