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

Remove ability to use vector3 as function #14517

Merged
merged 4 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions libraries/AP_AHRS/AP_AHRS_NavEKF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void AP_AHRS_NavEKF::update_DCM(bool skip_ins_update)
AP_AHRS_DCM::update(skip_ins_update);

// keep DCM attitude available for get_secondary_attitude()
_dcm_attitude(roll, pitch, yaw);
_dcm_attitude = {roll, pitch, yaw};
}

#if HAL_NAVEKF2_AVAILABLE
Expand Down Expand Up @@ -419,7 +419,7 @@ void AP_AHRS_NavEKF::reset(bool recover_eulers)
WITH_SEMAPHORE(_rsem);

AP_AHRS_DCM::reset(recover_eulers);
_dcm_attitude(roll, pitch, yaw);
_dcm_attitude = {roll, pitch, yaw};
#if HAL_NAVEKF2_AVAILABLE
if (_ekf2_started) {
_ekf2_started = EKF2.InitialiseFilter();
Expand All @@ -439,7 +439,7 @@ void AP_AHRS_NavEKF::reset_attitude(const float &_roll, const float &_pitch, con
WITH_SEMAPHORE(_rsem);

AP_AHRS_DCM::reset_attitude(_roll, _pitch, _yaw);
_dcm_attitude(roll, pitch, yaw);
_dcm_attitude = {roll, pitch, yaw};
#if HAL_NAVEKF2_AVAILABLE
if (_ekf2_started) {
_ekf2_started = EKF2.InitialiseFilter();
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_Compass/AP_Compass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ const Vector3f& Compass::getHIL(uint8_t instance) const
void Compass::_setup_earth_field(void)
{
// assume a earth field strength of 400
_hil.Bearth(400, 0, 0);
_hil.Bearth = {400, 0, 0};

// rotate _Bearth for inclination and declination. -66 degrees
// is the inclination in Canberra, Australia
Expand Down
11 changes: 8 additions & 3 deletions libraries/AP_Compass/AP_Compass_LIS3MDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ void AP_Compass_LIS3MDL::timer()
int16_t magz;
} data;
const float range_scale = 1000.0f / 6842.0f;
Vector3f field;

// check data ready
uint8_t status;
Expand All @@ -154,9 +153,15 @@ void AP_Compass_LIS3MDL::timer()
goto check_registers;
}

field(data.magx * range_scale, data.magy * range_scale, data.magz * range_scale);
{
Vector3f field{
data.magx * range_scale,
data.magy * range_scale,
data.magz * range_scale,
};

accumulate_sample(field, compass_instance);
accumulate_sample(field, compass_instance);
}

check_registers:
dev->check_next_register();
Expand Down
13 changes: 9 additions & 4 deletions libraries/AP_Compass/AP_Compass_RM3100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ void AP_Compass_RM3100::timer()
uint8_t magz_1;
uint8_t magz_0;
} data;
Vector3f field;

int32_t magx = 0;
int32_t magy = 0;
Expand Down Expand Up @@ -209,10 +208,16 @@ void AP_Compass_RM3100::timer()
magy >>= 8;
magz >>= 8;

// apply scaler and store in field vector
field(magx * _scaler, magy * _scaler, magz * _scaler);
{
// apply scaler and store in field vector
Vector3f field{
magx * _scaler,
magy * _scaler,
magz * _scaler
};

accumulate_sample(field, compass_instance);
accumulate_sample(field, compass_instance);
}

check_registers:
dev->check_next_register();
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_Compass/AP_Compass_SITL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void AP_Compass_SITL::_setup_eliptical_correcion(uint8_t i)
{
Vector3f diag = _sitl->mag_diag[i].get();
if (diag.is_zero()) {
diag(1,1,1);
diag = {1,1,1};
}
const Vector3f &diagonals = diag;
const Vector3f &offdiagonals = _sitl->mag_offdiag[i];
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_Math/AP_GeodesicGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ int AP_GeodesicGrid::_triangle_index(const Vector3f &v, bool inclusive)
w.z = -w.z;
break;
case 1:
w(w.y, w.z, -w.x);
w = {w.y, w.z, -w.x};
break;
case 2:
w(w.z, w.x, -w.y);
w = {w.z, w.x, -w.y};
break;
}

Expand Down
6 changes: 3 additions & 3 deletions libraries/AP_Math/matrix3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ void Matrix3<T>::to_euler(float *roll, float *pitch, float *yaw) const
template <typename T>
void Matrix3<T>::from_rotation(enum Rotation rotation)
{
(*this).a(1,0,0);
(*this).b(0,1,0);
(*this).c(0,0,1);
(*this).a = {1,0,0};
(*this).b = {0,1,0};
(*this).c = {0,0,1};

(*this).a.rotate(rotation);
(*this).b.rotate(rotation);
Expand Down
6 changes: 0 additions & 6 deletions libraries/AP_Math/vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ class Vector3
, y(y0)
, z(z0) {}

// function call operator
void operator ()(const T x0, const T y0, const T z0)
{
x= x0; y= y0; z= z0;
}

// test for equality
bool operator ==(const Vector3<T> &v) const;

Expand Down
4 changes: 2 additions & 2 deletions libraries/SITL/SIM_Calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void SITL::Calibration::update(const struct sitl_input &input)
_angular_velocity_control(input, rot_accel);
}

accel_body(0, 0, 0);
accel_body.zero();
update_dynamics(rot_accel);
update_position();
time_advance();
Expand Down Expand Up @@ -172,6 +172,6 @@ void SITL::Calibration::_calibration_poses(Vector3f& rot_accel)
r2.from_axis_angle(axis, rot_angle);
dcm = r2 * dcm;

accel_body(0, 0, -GRAVITY_MSS);
accel_body = {0, 0, -GRAVITY_MSS};
accel_body = dcm.transposed() * accel_body;
}
8 changes: 5 additions & 3 deletions libraries/SITL/SIM_FlightAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,11 @@ void FlightAxis::update(const struct sitl_input &input)
state.m_aircraftPositionX_MTR,
-state.m_altitudeASL_MTR - home.alt*0.01);

accel_body(state.m_accelerationBodyAX_MPS2,
state.m_accelerationBodyAY_MPS2,
state.m_accelerationBodyAZ_MPS2);
accel_body = {
float(state.m_accelerationBodyAX_MPS2),
float(state.m_accelerationBodyAY_MPS2),
float(state.m_accelerationBodyAZ_MPS2)
};

// accel on the ground is nasty in realflight, and prevents helicopter disarm
if (!is_zero(state.m_isTouchingGround)) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/SITL/SIM_Motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Motor::calculate_forces(const struct sitl_input &input,
Vector3f rotor_torque(0, 0, yaw_factor * motor_speed * yaw_scale);

// get thrust for untilted motor
thrust(0, 0, -motor_speed);
thrust = {0, 0, -motor_speed};

// define the arm position relative to center of mass
Vector3f arm(arm_scale * cosf(radians(angle)), arm_scale * sinf(radians(angle)), 0);
Expand Down
2 changes: 1 addition & 1 deletion libraries/SITL/SIM_XPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ bool XPlane::receive_data(void)
printf("X-Plane home reset dist=%f alt=%.1f/%.1f\n",
loc.get_distance(location), loc.alt*0.01f, location.alt*0.01f);
// reset home location
position_zero(-pos.x, -pos.y, -pos.z);
position_zero = {-pos.x, -pos.y, -pos.z};
home.lat = loc.lat;
home.lng = loc.lng;
home.alt = loc.alt;
Expand Down