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

Add support for NXP UWB position sensor #12956

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1f3aca5
Created basic NXP UWB driver
Sep 13, 2019
eb1c1fd
Added pozyx driver based on upstream.
cmic0 Feb 6, 2019
9a22db0
Added pozyx. Fixed hardfaults (increased pozyx stack allocation).
cmic0 Feb 7, 2019
392d5e6
Addedd pozyx_report to logger. Added debug messages.
cmic0 Feb 8, 2019
1cc3d0d
removed debug comments.
cmic0 Feb 18, 2019
fc8bc84
Removed deprecated dependency in CMakeLists.txt.
cmic0 Mar 4, 2019
3dc736c
Topic publishing
Sep 13, 2019
6dece35
Added basic bounds checking
Sep 13, 2019
6c1502f
Code cleanup and documentation
Sep 19, 2019
0356d6f
Removed baudrate option
Sep 19, 2019
2572824
Added message ID for pozyx_report message
Sep 19, 2019
2e56eb0
Some debugging
Sep 26, 2019
30a3ad0
Squash this commit in the rebase
Oct 10, 2019
f5fc125
Squash this commit too
Oct 10, 2019
525c22c
Removed landing point adjustment
Oct 17, 2019
0815ecc
Added comment for future reference
Oct 17, 2019
2317a63
Added UWB driver to NXP board
Oct 18, 2019
8e103ae
Added configurable baudrate
Oct 24, 2019
2d1c48b
Gave better names to pozyx_report message and UWB driver
Oct 24, 2019
e529840
Removed Pozyx driver (to be moved to another PR)
Oct 24, 2019
030a844
Fixed problem from rebase
Nov 21, 2019
2f71076
Fixed landing target pose issue
Jan 17, 2020
868960c
Added important stuff to startup script. Delete this before merging
Jan 24, 2020
1ccbf2f
Add support for new UWB MSG and Raw Distances.
LowOrbitIonCannon Feb 18, 2020
c6b415d
Fixed Typo
LowOrbitIonCannon Feb 18, 2020
efcf518
Phase 1 new Loc process
LowOrbitIonCannon Feb 27, 2020
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
19 changes: 18 additions & 1 deletion msg/uwb_report.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# UWB report message contains the coordinates of the vehicle measured by an ultra-wideband positioning system,
# such as Pozyx or NXP Rddrone.

uint64 timestamp # time since system start (microseconds)
# The coordinate frame of the UWB grid should be a Z-down, right-handed coordinate system.
# The yaw alignment is arbitrary, and stored in the yaw_offset field.
Expand All @@ -6,7 +9,21 @@ float32 pos_x # X position in the UWB grid frame, in meters
float32 pos_y # Y position in the UWB grid frame, in meters
float32 pos_z # Z position in the UWB grid frame, in meters

#float32 yaw_offset # Angle between the X axis of the UWB grid frame and true north. I.e., your compass heading if you face along the positive X axis
# The reason these values are kept in the uwb_report message is that we do not know the transform between the
# UWB coordinate system and the world coordinate system. Different UWB systems might have different mechanisms for
# this, so the UWB driver should handle it. Unless you
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you?

float32 target_pos_x # X position of the vehicle relative to the UWB origin (usually the landing point), in NED frame, in meters
float32 target_pos_y # Y position of the vehicle relative to the UWB origin (usually the landing point), in NED frame, in meters
float32 target_pos_z # Z position of the vehicle relative to the UWB origin (usually the landing point), in NED frame, in meters

# TODO: We could add the following fields. They would allow us to calculate the vehicle's global position by simply
# adding the offset (measured by the UWB system) to the origin lat/lon/alt.
# However, this functionality is not yet needed or used anywhere, so it is omitted for now to save space.

# bool global_pos_valid # True iff the values origin_lat, origin_lon, and origin_alt are all valid
# float32 origin_lat # Latitude of the point (0, 0, 0) of the UWB system
# float32 origin_lon # Longitude of the point (0, 0, 0) of the UWB system
# float32 origin_alt # Altitude of the point (0, 0, 0) of the UWB system

int16 var_x
int16 var_y
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/uwb/rddrone/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ serial_config:
port_config_param:
name: UWB_CONFIG
group: UWB
default: TEL2
default: ""
16 changes: 7 additions & 9 deletions src/drivers/uwb/rddrone/rddrone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void RDDrone::run()
_uwb_report.pos_y = _message.pos_y ;// / 100.0f;
_uwb_report.pos_z = _message.pos_z ;// / 100.0f;
_uwb_report.timestamp = hrt_absolute_time();
_uwb_pub.publish(_uwb_report);

_attitude_sub.update(&_vehicle_attitude);

// The end goal of this math is to get the position relative to the landing point in the NED frame.
Expand All @@ -182,15 +182,13 @@ void RDDrone::run()
// - Rotate by _nwu_to_ned to get into the NED frame
_current_position_ned = _nwu_to_ned * _rddrone_to_nwu * _current_position_rddrone;

_landing_target.timestamp = hrt_absolute_time();
_landing_target.rel_pos_valid = true;
_landing_target.rel_vel_valid = false;
_landing_target.is_static = true;
_landing_target.x_rel = -_current_position_ned(0);
_landing_target.y_rel = -_current_position_ned(1);
_landing_target.z_rel = -_current_position_ned(2);
// Now the position is the vehicle relative to the landing point. We need the landing point relative to
// the vehicle. So just negate everything.
_uwb_report.target_pos_x = _current_position_ned(0);
_uwb_report.target_pos_y = _current_position_ned(1);
_uwb_report.target_pos_z = _current_position_ned(2);

_landing_target_pub.publish(_landing_target);
_uwb_pub.publish(_uwb_report);

} else {
//PX4_ERR("Read %d bytes instead of %d.", (int) buffer_location, (int) sizeof(position_msg_t));
Expand Down
18 changes: 10 additions & 8 deletions src/modules/landing_target_estimator/LandingTargetEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,24 @@ void LandingTargetEstimator::_update_topics()
return;
}

if (!PX4_ISFINITE(_uwbReport.pos_y) || !PX4_ISFINITE(_uwbReport.pos_x) ||
!PX4_ISFINITE(_uwbReport.pos_z)) {
if (!PX4_ISFINITE(_uwbReport.target_pos_y) || !PX4_ISFINITE(_uwbReport.target_pos_x) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is y before x?

!PX4_ISFINITE(_uwbReport.target_pos_z)) {
return;
}

_new_sensorReport = true;
_uncertainty_scale = 1.0f;

// we're assuming the coordinate system is NEU
// to get the position relative to use we just need to negate x and y
// The coordinate system is NED (north-east-down).
// The coordinates "rel_pos_*" are the position of the landing point relative to the vehicle.
// The UWB report contains the position of the vehicle relative to the landing point.
// So, just negate all 3 components.
_sensor_report.timestamp = _uwbReport.timestamp;
_sensor_report.rel_pos_x = -_uwbReport.pos_x;
_sensor_report.rel_pos_y = -_uwbReport.pos_y;
_sensor_report.rel_pos_z = _uwbReport.pos_z;
_sensor_report.rel_pos_x = -_uwbReport.target_pos_x;
_sensor_report.rel_pos_y = -_uwbReport.target_pos_y;
_sensor_report.rel_pos_z = -_uwbReport.target_pos_z;

//PX4_WARN("data from uwb x: %.2f, y: %.2f", (double)_sensor_report.rel_pos_x,
//PX4_INFO("data from uwb x: %.2f, y: %.2f", (double)_sensor_report.rel_pos_x,
// (double)_sensor_report.rel_pos_y);
}
}
Expand Down