ROSBuzz_MISTLab/buzz_scripts/include/act/naviguation.bzz

36 lines
1.7 KiB
Plaintext
Raw Normal View History

GOTO_MAXVEL = 1.5 # m/steps
GOTO_MAXDIST = 250 # m.
GOTODIST_TOL = 0.4 # m.
GOTOANG_TOL = 0.1 # rad.
GPSlimit_CEPSUM = {.1={.lat=45.510400, .lng=-73.610421},
2018-11-09 15:25:58 -04:00
.2={.lat=45.510896, .lng=-73.608731},
.3={.lat=45.510355, .lng=-73.608404},
.4={.lat=45.509840, .lng=-73.610072}}
GPSlimit_PANGEAE = {.1={.lat=29.020871, .lng=-13.712477},
.2={.lat=29.019850, .lng=-13.712378},
.3={.lat=29.019875, .lng=-13.710096},
.4={.lat=29.021245, .lng=-13.710184}}
# Core naviguation function to travel to a GPS target location.
function goto_gps(transf) {
2018-11-09 15:25:58 -04:00
m_navigation = vec_from_gps(cur_goal.latitude, cur_goal.longitude, 0)
#print(" has to move ", math.vec2.length(m_navigation), math.vec2.angle(m_navigation))
if(math.vec2.length(m_navigation)>GOTO_MAXDIST)
log("Sorry this is too far (", math.vec2.length(m_navigation), " / ", GOTO_MAXDIST, " )")
else if(math.vec2.length(m_navigation) < GOTODIST_TOL and math.vec2.angle(m_navigation) < GOTOANG_TOL){ # reached destination
transf()
} else {
m_navigation = LimitSpeed(m_navigation, 1.0)
gf = {.0=m_navigation, .1=vec_from_gps(GPSlimit_PANGEAE[1].lat, GPSlimit_PANGEAE[1].lng, 0), .2=vec_from_gps(GPSlimit_PANGEAE[2].lat, GPSlimit_PANGEAE[2].lng, 0), .3=vec_from_gps(GPSlimit_PANGEAE[3].lat, GPSlimit_PANGEAE[3].lng, 0), .4=vec_from_gps(GPSlimit_PANGEAE[4].lat, GPSlimit_PANGEAE[4].lng, 0)}
2018-11-12 19:04:56 -04:00
geofence(gf)
2018-11-09 15:25:58 -04:00
#m_navigation = LCA(m_navigation)
goto_abs(m_navigation.x, m_navigation.y, cur_goal.altitude - pose.position.altitude, 0.0)
}
}
function LimitSpeed(vel_vec, factor){
if(math.vec2.length(vel_vec)>GOTO_MAXVEL*factor)
vel_vec = math.vec2.scale(vel_vec, GOTO_MAXVEL*factor/math.vec2.length(vel_vec))
return vel_vec
}