# File high_skills/walk.rb, line 7 def Walk.angle_range from, to (from/180.0*Math::PI)..(to/180.0*Math::PI) end
270 - 330 degrees @@right_range = (1.5*Math::PI)..((11.0/6.0)*Math::PI) 30 - 90 degrees @@left_range = ((1.0/6.0)*Math::PI)..(0.5*Math::PI) 75 - 90 degrees @@left_strafe_range = ((5.0/12.0)*Math::PI..(0.5*Math::PI)) 270 - 285 degrees @@right_strafe_range = (1.5*Math::PI..(19.0/12.0)*Math::PI) @@strafe_distance = 1.5
# File high_skills/walk.rb, line 45 def initialize target, validity_proc super() @agentInfo = Java::sk.fiit.jim.agent.AgentInfo.getInstance @target = target @validity_proc = validity_proc || Proc.new{return true} @ending = false @target_position = @agentInfo.ballControlPosition() # @target_phi = @target_position.getPhi() * 180.0 / Math::PI end
# File high_skills/walk.rb, line 197 def abs number Math.abs number end
# File high_skills/walk.rb, line 159 def back? target_position Angles.angle_diff(target_phi, Math::PI) < Math::PI / 6.0 end
# File high_skills/walk.rb, line 139 def back_and_close? @@back_range.include?(@target_position_phi) and (@target_position.getR <= @@strafe_distance) end
# File high_skills/walk.rb, line 193 def checkProgress # raise "Fallen!" if me.on_ground? end
# File high_skills/walk.rb, line 123 def close_enough? @agentInfo.isBallMine() end
def not_forward? targed_position @agentInfo.loguj(@agentInfo.whereIsTarget(targed_position)) not @agentInfo.whereIsTarget(targed_position).eql? 'front'
end
# File high_skills/walk.rb, line 189 def is_ball_mine? return @agentInfo.getIsBallMine end
# File high_skills/walk.rb, line 118 def is_current_skill? possibilities current_skill_name = currentSkill.nil? ? "null" : currentSkill.name possibilities.member?(current_skill_name) end
# File high_skills/walk.rb, line 143 def left_and_close? (@target_position.r <= @@strafe_distance) and @@left_strafe_range.include?(Angles.normalize(@target_position_phi)) end
# File high_skills/walk.rb, line 151 def left_and_distant? @@left_range.include? Angles.normalize(@target_position_phi) end
# File high_skills/walk.rb, line 58 def pickLowSkill #target_position = @agentInfo.ballControlPosition() # target_position = (ball relative position) if @target == :ball # @target = @target.set_z(0.0) # @agentInfo.loguj("phi" + @target_phi.to_s) is_still_valid = @validity_proc.call @ending = true if not is_still_valid # @agentInfo.loguj("end: "+@ending.to_s) return nil if not is_still_valid or @ending @agentInfo = Java::sk.fiit.jim.agent.AgentInfo.getInstance @target_position = @agentInfo.ballControlPosition() @target_position_phi = @target_position.getPhi() if @target_position_phi != nil @target_position_phi2 = @target_position_phi elsif @target_position_phi == nil and plan.see_ball? @target_position_phi = @target_position_phi2 end # @agentInfo.loguj(@agentInfo.getIsBallMine().to_s) # @agentInfo.loguj("straight: "+straight?.to_s) # @agentInfo.loguj("isBallMine: "+@agentInfo.isBallMine().to_s) case when (me.on_ground? or me.lying_on_back? or me.lying_on_belly?) : return nil # @plan << GetUp.new when (not see_ball?) : # @agentInfo.loguj("nevidim loptu dlhsie ako 5s") # return get_skill("turn_left_cont_20") return nil when (close_enough? and straight?) return nil # when back_and_very_close?: # return get_skill("turn_left_90") # return choose_turning_skill; when left_and_close?: return get_skill("step_left") when right_and_close?: return get_skill("step_right") when straight?: return get_skill("walk_forward") when back_and_close?: return get_skill("walk_back") when left_and_distant?: return get_skill("turn_left_cont_20") when right_and_distant?: return get_skill("turn_right_cont_20") # else # return get_skill("rollback") end # when back?(target_position) # #@agentInfo.setState('som chrbtom') # return # get_skill("turn_right_cont_20") end
# File high_skills/walk.rb, line 147 def right_and_close? (@target_position.r <= @@strafe_distance) and @@right_strafe_range.include?(Angles.normalize(@target_position_phi)) end
# File high_skills/walk.rb, line 155 def right_and_distant? @@right_range.include? Angles.normalize(@target_position.getPhi()) end
def straight? target_position
Angles.angle_diff(target_phi, 0.0) < Math::PI / 6.0
end
# File high_skills/walk.rb, line 131 def see_ball? ball.notSeenLongTime() < 5 end
# File high_skills/walk.rb, line 135 def straight? @@straight_range1.include?(@target_position_phi) or @@straight_range2.include?(@target_position_phi) end