-
Notifications
You must be signed in to change notification settings - Fork 986
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
Orientation enum name #342
Changes from 14 commits
d5f736a
5f06c83
3e7f786
9b8ece4
9162a50
0462cd9
08f4e8f
b44a461
8fedc4e
73cea49
1dbaf73
3779217
ad10689
ad7a7b4
5a7478d
872fdce
b9275aa
9f92221
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,25 +114,67 @@ distance_sensor: | |
hrlv_ez4_pub: | ||
id: 0 | ||
frame_id: "hrlv_ez4_sonar" | ||
orientation: 8 # RPY:{180.0, 0.0, 0.0} | ||
orientation: ROLL_180 # RPY:{180.0, 0.0, 0.0} | ||
field_of_view: 0.0 # XXX TODO | ||
send_tf: true | ||
sensor_position: {x: 0.0, y: 0.0, z: -0.1} | ||
lidarlite_pub: | ||
id: 1 | ||
frame_id: "lidarlite_laser" | ||
orientation: 8 | ||
orientation: ROLL_180 | ||
field_of_view: 0.0 # XXX TODO | ||
send_tf: true | ||
sensor_position: {x: 0.0, y: 0.0, z: -0.1} | ||
sonar_1_sub: | ||
subscriber: true | ||
id: 2 | ||
orientation: 8 | ||
orientation: ROLL_180 | ||
laser_1_sub: | ||
subscriber: true | ||
id: 3 | ||
orientation: 8 | ||
orientation: ROLL_180 | ||
|
||
## Currently available orientations: | ||
# "NONE" | ||
# "YAW_45" | ||
# "YAW_90" | ||
# "YAW_135" | ||
# "YAW_180" | ||
# "YAW_225" | ||
# "YAW_270" | ||
# "YAW_315" | ||
# "ROLL_180" | ||
# "ROLL_180_YAW_45" | ||
# "ROLL_180_YAW_90" | ||
# "ROLL_180_YAW_135" | ||
# "PITCH_180" | ||
# "ROLL_180_YAW_225" | ||
# "ROLL_180_YAW_270" | ||
# "ROLL_180_YAW_315" | ||
# "ROLL_90" | ||
# "ROLL_90_YAW_45" | ||
# "ROLL_90_YAW_90" | ||
# "ROLL_90_YAW_135" | ||
# "ROLL_270" | ||
# "ROLL_270_YAW_45" | ||
# "ROLL_270_YAW_90" | ||
# "ROLL_270_YAW_135" | ||
# "PITCH_90" | ||
# "PITCH_270" | ||
# "PITCH_180_YAW_90" | ||
# "PITCH_180_YAW_270" | ||
# "ROLL_90_PITCH_90" | ||
# "ROLL_180_PITCH_90" | ||
# "ROLL_270_PITCH_90" | ||
# "ROLL_90_PITCH_180" | ||
# "ROLL_270_PITCH_180" | ||
# "ROLL_90_PITCH_270" | ||
# "ROLL_180_PITCH_270" | ||
# "ROLL_270_PITCH_270" | ||
# "ROLL_90_PITCH_180_YAW_90" | ||
# "ROLL_90_YAW_270" | ||
# "ROLL_315_PITCH_315_YAW_315" | ||
## | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tooooo long. That should be in ros wiki (and link to that doc). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So add it :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why me? You also can edit. WIKI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do I add it? There's no place for enums there right now and this is not specific for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should have a general Enumerations page like http://wiki.ros.org/mavros/Enumerations. And then we add them all there (there's also others like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. |
||
|
||
# image_pub | ||
image: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,13 +43,13 @@ class DistanceSensorItem { | |
{ } | ||
|
||
// params | ||
bool is_subscriber; //!< this item is a subscriber, else is a publisher | ||
bool send_tf; //!< defines if a transform is sent or not | ||
uint8_t sensor_id; //!< id of the sensor | ||
bool is_subscriber; //!< this item is a subscriber, else is a publisher | ||
bool send_tf; //!< defines if a transform is sent or not | ||
uint8_t sensor_id; //!< id of the sensor | ||
double field_of_view; //!< FOV of the sensor | ||
tf::Vector3 position; //!< sensor position | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's one field that need to change type: Eigen::Vector3d. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. But please(!), instead, go to specific lines to change so to orientation handling work ok (that's the purpose of this PR). |
||
int orientation; //!< check orientation of sensor if != -1 | ||
int covariance; //!< in centimeters, current specification | ||
int orientation; //!< check orientation of sensor if != -1 | ||
int covariance; //!< in centimeters, current specification | ||
std::string frame_id; //!< frame id for send | ||
|
||
// topic handle | ||
|
@@ -64,7 +64,7 @@ class DistanceSensorItem { | |
|
||
private: | ||
std::vector<float> data; //!< array allocation for measurements | ||
size_t data_index; //!< array index | ||
size_t data_index; //!< array index | ||
|
||
/** | ||
* Calculate measurements variance to send to the FCU. | ||
|
@@ -75,7 +75,8 @@ class DistanceSensorItem { | |
data.push_back(range); | ||
else { | ||
data[data_index] = range; // it starts rewriting the values from 1st element | ||
if (++data_index > 49) data_index = 0; // restarts the index when achieves the last element | ||
if (++data_index > 49) | ||
data_index = 0; // restarts the index when achieves the last element | ||
} | ||
|
||
float average, variance, sum = 0, sum_ = 0; | ||
|
@@ -88,7 +89,7 @@ class DistanceSensorItem { | |
|
||
/* Compute the variance */ | ||
for (auto d : data) | ||
sum_ += pow((d - average), 2); | ||
sum_ += (d - average) * (d - average); | ||
|
||
variance = sum_ / data.size(); | ||
|
||
|
@@ -193,15 +194,17 @@ class DistanceSensorPlugin : public MavRosPlugin { | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave this if as is. Wrong place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not understanding this. |
||
if (sensor->orientation >= 0 && dist_sen.orientation != sensor->orientation) { | ||
ROS_ERROR_NAMED("distance_sensor", | ||
"DS: %s: received sensor data has different orientation (%d) than in config (%d)!", | ||
sensor->topic_name.c_str(), dist_sen.orientation, sensor->orientation); | ||
"DS: %s: received sensor data has different orientation (%s) than in config (%f)!", | ||
sensor->topic_name.c_str(), | ||
UAS::str_sensor_orientation(static_cast<MAV_SENSOR_ORIENTATION>(dist_sen.orientation)).c_str(), | ||
sensor->orientation); | ||
} | ||
|
||
auto range = boost::make_shared<sensor_msgs::Range>(); | ||
|
||
range->header = uas->synchronized_header(sensor->frame_id, dist_sen.time_boot_ms); | ||
|
||
range->min_range = dist_sen.min_distance * 1E-2; // in meters | ||
range->min_range = dist_sen.min_distance * 1E-2; // in meters | ||
range->max_range = dist_sen.max_distance * 1E-2; | ||
range->field_of_view = sensor->field_of_view; | ||
|
||
|
@@ -248,6 +251,7 @@ void DistanceSensorItem::range_cb(const sensor_msgs::Range::ConstPtr &msg) | |
|
||
if (covariance > 0) covariance_ = covariance; | ||
else covariance_ = uint8_t(calculate_variance(msg->range) * 1E2); // in cm | ||
/** @todo Propose changing covarince from uint8_t to float */ | ||
ROS_DEBUG_NAMED("distance_sensor", "DS: %d: sensor variance: %f", sensor_id, calculate_variance(msg->range) * 1E2); | ||
|
||
// current mapping, may change later | ||
|
@@ -323,6 +327,10 @@ DistanceSensorItem::Ptr DistanceSensorItem::create_item(DistanceSensorPlugin *ow | |
ROS_ERROR_NAMED("distance_sensor", "DS: %s: `orientation` not set!", topic_name.c_str()); | ||
p.reset(); return p; // nullptr | ||
} | ||
else if (p->orientation == -1) { | ||
ROS_ERROR_NAMED("distance_sensor", "DS: %s: defined orientation is not valid!", topic_name.c_str()); | ||
p.reset(); return p; // nullptr | ||
} | ||
|
||
// optional | ||
pnh.param("covariance", p->covariance, 0); | ||
|
@@ -336,6 +344,6 @@ DistanceSensorItem::Ptr DistanceSensorItem::create_item(DistanceSensorPlugin *ow | |
|
||
return p; | ||
} | ||
}; // namespace mavplugin | ||
}; // namespace mavplugin | ||
|
||
PLUGINLIB_EXPORT_CLASS(mavplugin::DistanceSensorPlugin, mavplugin::MavRosPlugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
std::string sensor_orientation
toconst std::string &sensor_orientation
.Also this function should be capable convert numeric value of enum (e.g. strtol() then check & return).
That needed for backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? And why not also
Eigen::Quaterniond sensor_orientation_matching
?Convert to what?
MAV_SENSOR_ORIENTATION orientation
is supposed to be a number, which is used as an index to return: orientation name in case ofUAS::str_sensor_orientation()
; and orientation values in case ofUAS::sensor_orientation_matching()
. Andorientation_from_str()
was created so we can return the orientation number/index if we give the orientation name. So I think we have all the functionalities we need.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this reduces object copying. What you want change in UAS::sensor_orientation_matching()?
Because there may be lots of configs with number representation. Why not just simply try to fall back to old behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I undestand, but:
... I can't. Can you code an example please?