Skip to content
This repository was archived by the owner on Mar 22, 2019. It is now read-only.
This repository was archived by the owner on Mar 22, 2019. It is now read-only.

Make PNav emulation "smooth" #47

@LucasYoung

Description

@LucasYoung

PNav emulation works by generating the quadcopter's location based on its waypoints. It simply iterates through every waypoint with a set delay, setting the location at each point.

This means that the quadcopter instantly jumps between waypoints, rather linearly moving between them. The purpose of this task is to make the quadcopter move between waypoints at a continuous, fixed speed.

Area of interest: line 455 of PNav.cpp. This is where we check the quadcopter's location. In the case of emulation, we generate a location based on the waypoints. Here is how we generate the location right now:
`

if(mission_waypoints.size() == 0) {
  lpos.x = LNED_0(0);
  lpos.y = LNED_0(1);
  lpos.z = LNED_0(2);
  gpos.lat = CALPOLY_LAT;
  gpos.lon = CALPOLY_LON;
  gpos.alt = CALPOLY_ALT;
}
else {
  t1_flight_delay = steady_clock::now();
  if ((((duration_cast<milliseconds>(t1_flight_delay - t0_flight_delay).count()) >
        (1 / configs->heartbeat_freq) * 1000)))
  {
    lpos.x = sp.x;
    lpos.y = sp.y;
    lpos.z = sp.z;

    coordLocalNED lTemp(lpos.x, lpos.y, lpos.z);
    coordLLA gTemp = waypoints::LocalNEDtoLLA(*configs, lTemp, AngleType::DEGREES);

    //std::cerr << "gpos: " << gTemp << std::endl;
    gpos.lat = gTemp(0) * 1E7;
    gpos.lon = gTemp(1) * 1E7;
    gpos.alt = gTemp(2) * 1E3; 

    t0_flight_delay = steady_clock::now();
  }`

So if the waypoints haven't been set, just set the location to a hardcoded place (Cal Poly). Otherwise, check if it's time to set the location to the next waypoint by getting the current time and comparing it to the last time we set the location.

To solve this task, you will need to use the difference in time instead to calculate how far the quadcopter should be between the two waypoints.

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions