Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix px4 connection for wsl 2. #3603

Merged
merged 44 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
dd27458
fix px4 connection for wsl 2.
lovettchris Apr 16, 2021
b30ee91
enable throttling to 250 hz and fix bug in lockstep, should not send …
lovettchris Apr 16, 2021
1f3368b
add mavlink 2 support
lovettchris Apr 16, 2021
1c15604
make test terminate when it finds a problem, so you can capture the r…
lovettchris Apr 16, 2021
006d4e2
Merge settings improvements from PR 3546
lovettchris Apr 16, 2021
3b82fef
fix build and update docs.
lovettchris Apr 16, 2021
30ab123
fix unreal build
lovettchris Apr 16, 2021
b0b5de3
compute checksum on telemetry messages.
lovettchris Apr 17, 2021
71ff206
fix compiler warning.
lovettchris Apr 17, 2021
24d1bb6
Move telemetry to separate thread to get it out of the update() loop.…
lovettchris Apr 18, 2021
62048e5
guard telemetry variables with a mutex.
lovettchris Apr 18, 2021
938046f
make actuator delay an average
lovettchris Apr 18, 2021
9608bb4
add missing script files
lovettchris Apr 18, 2021
cb46217
fix pwsh support
lovettchris Apr 18, 2021
cfc7eec
add update_time to mavlinktelemetry
lovettchris Apr 18, 2021
642539a
Merge branch 'master' into clovett/mavlinkfixes
lovettchris Apr 19, 2021
f943770
add requirements.txt for pythonclient.
lovettchris Apr 20, 2021
92f3f3f
add info on how to use mavlink logs and px4 log viewer to debug a bad…
lovettchris Apr 20, 2021
bf71a53
Merge branch 'clovett/mavlinkfixes' of github.com:microsoft/AirSim in…
lovettchris Apr 20, 2021
db62395
Merge branch 'master' into clovett/mavlinkfixes
lovettchris Apr 20, 2021
cbdff5b
fix install link
lovettchris Apr 20, 2021
d48f5c0
add link to logging.
lovettchris Apr 20, 2021
65c3b4b
Merge branch 'master' into clovett/mavlinkfixes
lovettchris Apr 24, 2021
f7d2fea
fix drone server wsl2 connection.
lovettchris Apr 24, 2021
ad5534a
CR feedback.
lovettchris Apr 27, 2021
3d8f8b2
fix ros wrapper compile.
lovettchris Apr 27, 2021
e894d3a
script to test flying up high
lovettchris Apr 28, 2021
9d2012e
merge master
lovettchris Apr 28, 2021
0b81265
fix missing stopLoggingReceiveMessage
lovettchris Apr 28, 2021
f72de5f
nasty merge with master
lovettchris Apr 28, 2021
62b08da
consistency with logviewer logging and add docs.
lovettchris Apr 28, 2021
6db1f21
Pause physics update loop while waiting for actuator controls during …
lovettchris Apr 28, 2021
6fdb9b7
add missing update
lovettchris Apr 28, 2021
d28ace6
cleanup unnecessary cmake messages.
lovettchris Apr 28, 2021
f28f32b
Fix code formatting
lovettchris Apr 29, 2021
b717da4
fix typos.
lovettchris Apr 29, 2021
609031b
fix typo in udpate_rate
lovettchris Apr 29, 2021
def8bc0
fix bugs.
lovettchris Apr 30, 2021
c04924f
clang format
lovettchris Apr 30, 2021
6c747c7
cr fixes
lovettchris Apr 30, 2021
ade1289
Merge branch 'master' into clovett/mavlinkfixes
lovettchris May 3, 2021
e434f41
Add info on lockstep and steppable clock.
lovettchris May 3, 2021
ef5a6a6
add lockstep to toc
lovettchris May 4, 2021
6db5c7f
Make sure each buffer is zero'd out before reading bytes. Remove unn…
lovettchris May 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 59 additions & 150 deletions AirLib/include/common/AirSimSettings.hpp

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions AirLib/include/common/UpdatableContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@ class UpdatableContainer : public UpdatableObject {
const TUpdatableObjectPtr& at(uint index) const { members_.at(index); }
TUpdatableObjectPtr& at(uint index) { return members_.at(index); }
//allow to override membership modifications
virtual void clear() { members_.clear(); }
virtual void insert(TUpdatableObjectPtr member) { members_.push_back(member); }
virtual void erase_remove(TUpdatableObjectPtr obj) {
members_.erase(std::remove(members_.begin(), members_.end(), obj), members_.end()); }
virtual void clear() {
for (auto m : members_) {
m->setParent(nullptr);
}
members_.clear();
}
virtual void insert(TUpdatableObjectPtr member) {
member->setParent(this);
members_.push_back(member);
}
virtual void erase_remove(TUpdatableObjectPtr member) {
member->setParent(nullptr);
members_.erase(std::remove(members_.begin(), members_.end(), member), members_.end());
}


public:
//*** Start: UpdatableState implementation ***//
Expand Down
19 changes: 18 additions & 1 deletion AirLib/include/common/UpdatableObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Do not call reset() from constructor or initialization because that will produce
init->reset calls for base-derived class that would be incorrect.
*/


class UpdatableObject {
public:
void reset()
Expand Down Expand Up @@ -73,6 +72,22 @@ class UpdatableObject {
return ClockFactory::get();
}

UpdatableObject* getParent() {
return parent_;
}

void setParent(UpdatableObject* container) {
parent_ = container;
}

std::string getName(){
return name_;
}

void setName(const std::string& name) {
this->name_ = name;
}

protected:
virtual void resetImplementation() = 0;
virtual void failResetUpdateOrdering(std::string err)
Expand All @@ -84,6 +99,8 @@ class UpdatableObject {
bool reset_called = false;
bool update_called = false;
bool reset_in_progress = false;
UpdatableObject* parent_ = nullptr;
std::string name_;
};

}} //namespace
Expand Down
3 changes: 1 addition & 2 deletions AirLib/include/common/common_utils/FileSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class FileSystem
break;
}
if (i < 0) return "";
auto ui = static_cast<uint>(i);
return str.substr(ui, len - ui);
return str.substr(i, len - i);
}

static std::string getLogFolderPath(bool folder_timestamp, const std::string& parent = "")
Expand Down
13 changes: 10 additions & 3 deletions AirLib/include/common/common_utils/ScheduledExecutor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@ class ScheduledExecutor {
void pause(bool is_paused)
{
paused_ = is_paused;
pause_period_start_ = 0; // cancel any pause period.
}

bool isPaused() const
{
return paused_;
}

void pauseForTime(double seconds)
{
pause_period_start_ = nanos();
pause_period_ = static_cast<TTimeDelta>(1E9 * seconds);
paused_ = true;
}

void continueForTime(double seconds)
{
pause_period_start_ = nanos();
Expand All @@ -65,6 +73,7 @@ class ScheduledExecutor {

void continueForFrames(uint32_t frames)
{
pause_period_start_ = 0; // cancel any pause period.
frame_countdown_enabled_ = true;
targetFrameNumber_ = frames + currentFrameNumber_;
paused_ = false;
Expand Down Expand Up @@ -174,9 +183,7 @@ class ScheduledExecutor {

if (pause_period_start_ > 0) {
if (nanos() - pause_period_start_ >= pause_period_) {
if (! isPaused())
pause(true);

pause(!isPaused());
pause_period_start_ = 0;
}
}
Expand Down
3 changes: 2 additions & 1 deletion AirLib/include/physics/FastPhysicsEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class FastPhysicsEngine : public PhysicsEngineBase {
public:
FastPhysicsEngine(bool enable_ground_lock = true, Vector3r wind = Vector3r::Zero())
: enable_ground_lock_(enable_ground_lock), wind_(wind)
{
{
setName("FastPhysicsEngine");
}

//*** Start: UpdatableState implementation ***//
Expand Down
2 changes: 2 additions & 0 deletions AirLib/include/physics/PhysicsBody.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ class PhysicsBody : public UpdatableObject {
inertia_ = inertia;
inertia_inv_ = inertia_.inverse();
environment_ = environment;
environment_->setParent(this);
kinematics_ = kinematics;
kinematics_->setParent(this);
}

//enable physics body detection
Expand Down
28 changes: 2 additions & 26 deletions AirLib/include/physics/PhysicsEngineBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace msr { namespace airlib {

class PhysicsEngineBase : public UpdatableObject {
class PhysicsEngineBase : public UpdatableContainer<PhysicsBody*> {
public:
virtual void update() override
{
Expand All @@ -23,31 +23,7 @@ class PhysicsEngineBase : public UpdatableObject {
//default nothing to report for physics engine
}

//TODO: reduce copy-past from UpdatableContainer which has same code
/********************** Container interface **********************/
typedef PhysicsBody* TUpdatableObjectPtr;
typedef vector<TUpdatableObjectPtr> MembersContainer;
typedef typename MembersContainer::iterator iterator;
typedef typename MembersContainer::const_iterator const_iterator;
typedef typename MembersContainer::value_type value_type;

iterator begin() { return members_.begin(); }
iterator end() { return members_.end(); }
const_iterator begin() const { return members_.begin(); }
const_iterator end() const { return members_.end(); }
uint size() const { return static_cast<uint>(members_.size()); }
const TUpdatableObjectPtr &at(uint index) const { return members_.at(index); }
TUpdatableObjectPtr &at(uint index) { return members_.at(index); }
//allow to override membership modifications
virtual void clear() { members_.clear(); }
virtual void insert(TUpdatableObjectPtr member) { members_.push_back(member); }
virtual void erase_remove(TUpdatableObjectPtr obj) {
members_.erase(std::remove(members_.begin(), members_.end(), obj), members_.end()); }

virtual void setWind(const Vector3r& wind) {};

private:
MembersContainer members_;
virtual void setWind(const Vector3r& wind) { unused(wind); };
};


Expand Down
5 changes: 4 additions & 1 deletion AirLib/include/physics/PhysicsWorld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

namespace msr { namespace airlib {

class PhysicsWorld {
class PhysicsWorld : UpdatableObject {
public:
PhysicsWorld(std::unique_ptr<PhysicsEngineBase> physics_engine, const std::vector<UpdatableObject*>& bodies,
uint64_t update_period_nanos = 3000000LL, bool state_reporter_enabled = false,
bool start_async_updator = true
)
: world_(std::move(physics_engine))
{
setName("PhysicsWorld");
enableStateReport(state_reporter_enabled);
update_period_nanos_ = update_period_nanos;
initializeWorld(bodies, start_async_updator);
Expand Down Expand Up @@ -108,6 +109,8 @@ class PhysicsWorld {
world_.setFrameNumber(frameNumber);
}

void resetImplementation() override {}

private:
void initializeWorld(const std::vector<UpdatableObject*>& bodies, bool start_async_updator)
{
Expand Down
8 changes: 7 additions & 1 deletion AirLib/include/physics/World.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class World : public UpdatableContainer<UpdatableObject*> {
: physics_engine_(std::move(physics_engine))
{
World::clear();

setName("World");
physics_engine_->setParent(this);
if (physics_engine)
physics_engine_->clear();
}
Expand Down Expand Up @@ -118,6 +119,11 @@ class World : public UpdatableContainer<UpdatableObject*> {
return executor_.isPaused();
}

void pauseForTime(double seconds)
{
executor_.pauseForTime(seconds);
}

void continueForTime(double seconds)
{
executor_.continueForTime(seconds);
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/sensors/SensorBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SensorBase : public UpdatableObject {

private:
//ground truth can be shared between many sensors
GroundTruth ground_truth_;
GroundTruth ground_truth_ = { nullptr, nullptr };
std::string name_ = "";
};

Expand Down
21 changes: 10 additions & 11 deletions AirLib/include/sensors/SensorFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ class SensorFactory {
public:

// creates one sensor from settings
virtual std::unique_ptr<SensorBase> createSensorFromSettings(
virtual std::shared_ptr<SensorBase> createSensorFromSettings(
const AirSimSettings::SensorSetting* sensor_setting) const
{
switch (sensor_setting->sensor_type) {
case SensorBase::SensorType::Imu:
return std::unique_ptr<ImuSimple>(new ImuSimple(*static_cast<const AirSimSettings::ImuSetting*>(sensor_setting)));
return std::shared_ptr<ImuSimple>(new ImuSimple(*static_cast<const AirSimSettings::ImuSetting*>(sensor_setting)));
case SensorBase::SensorType::Magnetometer:
return std::unique_ptr<MagnetometerSimple>(new MagnetometerSimple(*static_cast<const AirSimSettings::MagnetometerSetting*>(sensor_setting)));
return std::shared_ptr<MagnetometerSimple>(new MagnetometerSimple(*static_cast<const AirSimSettings::MagnetometerSetting*>(sensor_setting)));
case SensorBase::SensorType::Gps:
return std::unique_ptr<GpsSimple>(new GpsSimple(*static_cast<const AirSimSettings::GpsSetting*>(sensor_setting)));
return std::shared_ptr<GpsSimple>(new GpsSimple(*static_cast<const AirSimSettings::GpsSetting*>(sensor_setting)));
case SensorBase::SensorType::Barometer:
return std::unique_ptr<BarometerSimple>(new BarometerSimple(*static_cast<const AirSimSettings::BarometerSetting*>(sensor_setting)));
return std::shared_ptr<BarometerSimple>(new BarometerSimple(*static_cast<const AirSimSettings::BarometerSetting*>(sensor_setting)));
default:
throw new std::invalid_argument("Unexpected sensor type");
}
}

// creates sensor-collection
virtual void createSensorsFromSettings(
const std::map<std::string, std::unique_ptr<AirSimSettings::SensorSetting>>& sensors_settings,
const std::map<std::string, std::shared_ptr<AirSimSettings::SensorSetting>>& sensors_settings,
SensorCollection& sensors,
vector<unique_ptr<SensorBase>>& sensor_storage) const
vector<shared_ptr<SensorBase>>& sensor_storage) const
{
for (const auto& sensor_setting_pair : sensors_settings) {
const AirSimSettings::SensorSetting* sensor_setting = sensor_setting_pair.second.get();
Expand All @@ -49,11 +49,10 @@ class SensorFactory {
if (sensor_setting == nullptr || !sensor_setting->enabled)
continue;

std::unique_ptr<SensorBase> sensor = createSensorFromSettings(sensor_setting);
std::shared_ptr<SensorBase> sensor = createSensorFromSettings(sensor_setting);
if (sensor) {
SensorBase* sensor_temp = sensor.get();
sensor_storage.push_back(std::move(sensor));
sensors.insert(sensor_temp, sensor_setting->sensor_type);
sensor_storage.push_back(sensor);
sensors.insert(sensor.get(), sensor_setting->sensor_type);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions AirLib/include/sensors/barometer/BarometerSimple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BarometerSimple : public BarometerBase {
//GM process that would do random walk for pressure factor
pressure_factor_.initialize(params_.pressure_factor_tau, params_.pressure_factor_sigma, 0);

uncorrelated_noise_ = RandomGeneratorGausianR(0.0f, params_.unnorrelated_noise_sigma);
uncorrelated_noise_ = RandomGeneratorGausianR(0.0f, params_.uncorrelated_noise_sigma);
//correlated_noise_.initialize(params_.correlated_noise_tau, params_.correlated_noise_sigma, 0.0f);

//initialize frequency limiter
Expand Down Expand Up @@ -76,7 +76,7 @@ class BarometerSimple : public BarometerBase {
auto altitude = ground_truth.environment->getState().geo_point.altitude;
auto pressure = EarthUtils::getStandardPressure(altitude);

//add drift in pressure, about 10m change per hour
//add drift in pressure, about 10m change per hour using default settings.
pressure_factor_.update();
pressure += pressure * pressure_factor_.getOutput();

Expand Down
15 changes: 11 additions & 4 deletions AirLib/include/sensors/barometer/BarometerSimpleParams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define msr_airlib_BarometerSimpleParams_hpp

#include "common/Common.hpp"
#include "common/AirSimSettings.hpp"


namespace msr { namespace airlib {
Expand Down Expand Up @@ -33,14 +34,14 @@ struct BarometerSimpleParams {

real_T correlated_noise_sigma = 0.27f;
real_T correlated_noise_tau = 0.87f;
real_T unnorrelated_noise_sigma = 0.24f;
real_T uncorrelated_noise_sigma = 0.24f;
*/

//Experiments for MEAS MS56112 sensor shows 0.021mbar, datasheet has resoultion of 0.027mbar @ 1024
//http://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=MS5611-01BA03&DocType=Data+Sheet&DocLang=English
real_T unnorrelated_noise_sigma = 0.027f * 100;
real_T uncorrelated_noise_sigma = 0.027f * 100;
//jMavSim uses below
//real_T unnorrelated_noise_sigma = 0.1f;
//real_T uncorrelated_noise_sigma = 0.1f;

//see PX4 param reference for EKF: https://dev.px4.io/en/advanced/parameter_reference.html
real_T update_latency = 0.0f; //sec
Expand All @@ -49,7 +50,13 @@ struct BarometerSimpleParams {

void initializeFromSettings(const AirSimSettings::BarometerSetting& settings)
{
unused(settings);
const auto& json = settings.settings;
pressure_factor_sigma = json.getFloat("PressureFactorSigma", pressure_factor_sigma);
pressure_factor_tau = json.getFloat("PressureFactorTau", pressure_factor_tau);
uncorrelated_noise_sigma = json.getFloat("UncorrelatedNoiseSigma", uncorrelated_noise_sigma);
update_latency = json.getFloat("UpdateLatency", update_latency);
update_frequency = json.getFloat("UpdateFrequency", update_frequency);
startup_delay = json.getFloat("StartupDelay", startup_delay);
}
};

Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/sensors/distance/DistanceSimple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DistanceSimple : public DistanceBase {
// initialize params
params_.initializeFromSettings(setting);

uncorrelated_noise_ = RandomGeneratorGausianR(0.0f, params_.unnorrelated_noise_sigma);
uncorrelated_noise_ = RandomGeneratorGausianR(0.0f, params_.uncorrelated_noise_sigma);
//correlated_noise_.initialize(params_.correlated_noise_tau, params_.correlated_noise_sigma, 0.0f);


Expand Down
Loading