User Tools

Site Tools


darwin_walk_backward_with_cv

This is an old revision of the document!


How to Program Darwin OP 2 to Walk Backward with Computer Vision

Author: Yu Hang He Email: hey6@unlv.nevada.edu
Date: Last modified on <11/27/17>
Keywords: Darwin OP 2, C Programming, Robotis OP 2, Computer Vision

This tutorial will demonstrate how to program Darwin OP 2 to walk backward while guided by computer vision. In previous tutorial, tutorial for walking toward target, we used BallFollower class to target the marker. However, the BallFollower class will only work with forward motion. This tutorial will provide some insight into the process of program Darwin OP 2 to walk backward with computer vision and it will take approximately 1 hour to complete.

Motivation and Audience

This tutorial's motivation is to demonstrate and document how to program Darwin OP 2 to walk backward. This tutorial assumes the reader has the following background and interests:

  • Familiar with handling Darwin OP 2
  • Familiar with Cplusplus/C programming language
  • Familiar with Cplusplus/C codes on Darwin OP 2

The rest of this tutorial is presented as follows:

Programming

Even though BallFollower class will not directly work with walking backward, the basic algorithm used in the class is applicable to backward motion.

There are 3 parameter in walking_tuner that cannot be saved: Step forward/back (mm), Step right/left (mm), and Step Direction (degree). Instead, these variables should be updated constantly by your program during Darwin OP 2's walking process.

Below is a sample program that demonstrates Darwin OP 2 walking backward. Place both main.cpp and Makefile inside a new folder in directory robotisop2/Linux/project/tutorial/. Then, type make command to compile executable and type ./walk_backward to execute program.

| main.cpp
int m_FollowMaxRLTurn = 35.0, m_UnitRLTurn = 1.0, m_GoalRLTurn = 0, m_RLTurn = 0;
 
            if(Action::GetInstance()->IsRunning() == 0)
            {
		Head::GetInstance()->m_Joint.SetEnableHeadOnly(true, true);
                Walking::GetInstance()->m_Joint.SetEnableBodyWithoutHead(true, true);
 
                if(Walking::GetInstance()->IsRunning() == false){
                Walking::GetInstance()->X_MOVE_AMPLITUDE = 30.0;
                Walking::GetInstance()->A_MOVE_AMPLITUDE = 4.0;
                Walking::GetInstance()->Start();
                }
 
                else if(_marker_found == 1 && _backpedal == 1)
                {
                    double pan = MotionStatus::m_CurrentJoints.GetAngle(JointData::ID_HEAD_PAN);
                    double pan_range = Head::GetInstance()->GetLeftLimitAngle();
                    double pan_percent = pan / pan_range;
 
                    m_GoalRLTurn = m_FollowMaxRLTurn * pan_percent;
                    if(m_RLTurn < m_GoalRLTurn)
              		m_RLTurn += m_UnitRLTurn;
              	    else if(m_RLTurn > m_GoalRLTurn)
              		m_RLTurn -= m_UnitRLTurn;
 
              	    Walking::GetInstance()->A_MOVE_AMPLITUDE = (m_RLTurn);
                    Walking::GetInstance()->X_MOVE_AMPLITUDE = -15.0;
 
                }
                else
                {
                    Walking::GetInstance()->X_MOVE_AMPLITUDE = -15.0;
                    Walking::GetInstance()->A_MOVE_AMPLITUDE = 0.0;
                }
             }

Demonstration

In this demonstration, I successfully compile and execute the above programs

Final Words

This tutorial's objective was to demonstrate how to program Darwin OP 2 to walk backward.

For questions, clarifications, etc, Email: hey6@unlv.nevada.edu

darwin_walk_backward_with_cv.1512343285.txt.gz · Last modified: by yuhanghe