Skip to content

Commit

Permalink
Merge pull request #10459 from Scavanger/Geozones
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca authored Nov 15, 2024
2 parents 9fb51e0 + 3d6b235 commit abab92a
Show file tree
Hide file tree
Showing 25 changed files with 3,358 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
}
],
"version": 4
}
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cmath": "c",
"ranges": "c",
"navigation.h": "c",
"rth_trackback.h": "c"
"rth_trackback.h": "c",
"platform.h": "c",
"timer.h": "c",
"bus.h": "c"
Expand All @@ -15,4 +15,4 @@
"editor.expandTabs": true,
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, BreakBeforeBraces: Mozilla }"

}
}
70 changes: 70 additions & 0 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,76 @@ Yaw Iterm is frozen when bank angle is above this threshold [degrees]. This solv

---

### geozone_avoid_altitude_range

Altitude range in which an attempt is made to avoid a geozone upwards

| Default | Min | Max |
| --- | --- | --- |
| 5000 | 0 | 1000000 |

---

### geozone_detection_distance

Distance from which a geozone is detected

| Default | Min | Max |
| --- | --- | --- |
| 50000 | 0 | 1000000 |

---

### geozone_mr_stop_distance

Distance in which multirotors stops before the border

| Default | Min | Max |
| --- | --- | --- |
| 15000 | 0 | 100000 |

---

### geozone_no_way_home_action

Action if RTH with active geozones is unable to calculate a course to home

| Default | Min | Max |
| --- | --- | --- |
| RTH | | |

---

### geozone_safe_altitude_distance

Vertical distance that must be maintained to the upper and lower limits of the zone.

| Default | Min | Max |
| --- | --- | --- |
| 1000 | 0 | 10000 |

---

### geozone_safehome_as_inclusive

Treat nearest safehome as inclusive geozone

| Default | Min | Max |
| --- | --- | --- |
| OFF | OFF | ON |

---

### geozone_safehome_zone_action

Fence action for safehome zone

| Default | Min | Max |
| --- | --- | --- |
| NONE | | |

---

### gimbal_pan_channel

Gimbal pan rc channel index. 0 is no channel.
Expand Down
1 change: 1 addition & 0 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ main_sources(COMMON_SRC
navigation/navigation_pos_estimator_flow.c
navigation/navigation_private.h
navigation/navigation_rover_boat.c
navigation/navigation_geozone.c
navigation/sqrt_controller.c
navigation/sqrt_controller.h
navigation/rth_trackback.c
Expand Down
83 changes: 83 additions & 0 deletions src/main/common/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ typedef union {
};
} fpVector3_t;

typedef union {
float v[2];
struct {
float x,y;
};
} fpVector2_t;

typedef struct {
float m[3][3];
} fpMat3_t;
Expand Down Expand Up @@ -116,3 +123,79 @@ static inline fpVector3_t * vectorScale(fpVector3_t * result, const fpVector3_t
*result = ab;
return result;
}

static inline fpVector3_t* vectorSub(fpVector3_t* result, const fpVector3_t* a, const fpVector3_t* b)
{
fpVector3_t ab;

ab.x = a->x - b->x;
ab.y = a->y - b->y;
ab.z = a->z - b->z;

*result = ab;
return result;
}

static inline float vectorDotProduct(const fpVector3_t* a, const fpVector3_t* b)
{
return a->x * b->x + a->y * b->y + a->z * b->z;
}

static inline float vector2NormSquared(const fpVector2_t * v)
{
return sq(v->x) + sq(v->y);
}

static inline fpVector2_t* vector2Normalize(fpVector2_t* result, const fpVector2_t* v)
{
float sqa = vector2NormSquared(v);
float length = sqrtf(sqa);
if (length != 0) {
result->x = v->x / length;
result->y = v->y / length;
} else {
result->x = 0;
result->y = 0;
}
return result;
}


static inline fpVector2_t* vector2Sub(fpVector2_t* result, const fpVector2_t* a, const fpVector2_t* b)
{
fpVector2_t ab;

ab.x = a->x - b->x;
ab.y = a->y - b->y;

*result = ab;
return result;
}

static inline fpVector2_t * vector2Add(fpVector2_t * result, const fpVector2_t * a, const fpVector2_t * b)
{
fpVector2_t ab;

ab.x = a->x + b->x;
ab.y = a->y + b->y;

*result = ab;
return result;
}


static inline float vector2DotProduct(const fpVector2_t* a, const fpVector2_t* b)
{
return a->x * b->x + a->y * b->y;
}

static inline fpVector2_t * vector2Scale(fpVector2_t * result, const fpVector2_t * a, const float b)
{
fpVector2_t ab;

ab.x = a->x * b;
ab.y = a->y * b;

*result = ab;
return result;
}
5 changes: 4 additions & 1 deletion src/main/config/parameter_group_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@
#define PG_GIMBAL_CONFIG 1039
#define PG_GIMBAL_SERIAL_CONFIG 1040
#define PG_HEADTRACKER_CONFIG 1041
#define PG_INAV_END PG_HEADTRACKER_CONFIG
#define PG_GEOZONE_CONFIG 1042
#define PG_GEOZONES 1043
#define PG_GEOZONE_VERTICES 1044
#define PG_INAV_END PG_GEOZONE_VERTICES

// OSD configuration (subject to change)
//#define PG_OSD_FONT_CONFIG 2047
Expand Down
Loading

0 comments on commit abab92a

Please sign in to comment.