-
Notifications
You must be signed in to change notification settings - Fork 655
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
Feature/timestamp from phaselock angle #481
base: master
Are you sure you want to change the base?
Changes from all commits
dda64b3
105ee42
502037a
8093567
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 |
---|---|---|
|
@@ -147,6 +147,31 @@ VelodyneDriver::VelodyneDriver(ros::NodeHandle node, | |
// which is used in velodyne packets | ||
config_.cut_angle = int((cut_angle*360/(2*M_PI))*100); | ||
|
||
double timestamp_angle; | ||
private_nh.param("timestamp_angle", timestamp_angle, -0.01); | ||
if (timestamp_angle < 0.0) | ||
{ | ||
ROS_INFO_STREAM("Time at specific angle feature deactivated."); | ||
} | ||
else if (timestamp_angle < (2*M_PI)) | ||
{ | ||
ROS_INFO_STREAM("Time at specific angle feature activated. " | ||
"Set to " << timestamp_angle << " rad."); | ||
if (config_.timestamp_first_packet){ | ||
ROS_ERROR_STREAM("timestamp_first_packet AND timestamp_angle configured! timestamp_first_packet will be used!"); | ||
} | ||
} | ||
else | ||
{ | ||
ROS_ERROR_STREAM("timestamp_angle is out of range. Allowed range is " | ||
<< "between 0.0 and 2*PI or negative values to deactivate this feature."); | ||
timestamp_angle = -0.01; | ||
} | ||
|
||
// Convert timestamp_angle from radian to one-hundredth degree, | ||
// which is used in velodyne packets | ||
config_.timestamp_angle = int((timestamp_angle*360/(2*M_PI))*100); | ||
Comment on lines
+150
to
+173
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. This whole initialization function is getting long. I think the Radian to hundredth degree could be a function since it is now used twice. This timestamp validation code could be in its own function. I'm also concerned about the timestamp_angle param being overwritten |
||
|
||
int udp_port; | ||
private_nh.param("port", udp_port, (int) DATA_PORT_NUMBER); | ||
|
||
|
@@ -213,6 +238,8 @@ bool VelodyneDriver::poll(void) | |
// Allocate a new shared pointer for zero-copy sharing with other nodelets. | ||
velodyne_msgs::VelodyneScanPtr scan(new velodyne_msgs::VelodyneScan); | ||
|
||
ros::Time time_angle; | ||
|
||
if( config_.cut_angle >= 0) //Cut at specific angle feature enabled | ||
{ | ||
scan->packets.reserve(config_.npackets); | ||
|
@@ -237,6 +264,14 @@ bool VelodyneDriver::poll(void) | |
last_azimuth_ = azimuth; | ||
continue; | ||
} | ||
|
||
if((last_azimuth_ < config_.timestamp_angle && config_.timestamp_angle <= azimuth) | ||
|| ( config_.timestamp_angle <= azimuth && azimuth < last_azimuth_) | ||
|| (azimuth < last_azimuth_ && last_azimuth_ < config_.timestamp_angle)) | ||
Comment on lines
+268
to
+270
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. The logic in this if statement is the same logic as line 275 and should really be placed in its own function to be used on both lines
Within the function, I think you need a comment just explaining the logic since it was not immediately obvious to me.
I'm not even completely sure what is going on since there are other cases listed in the issue here but I don't know how those show up #174 |
||
{ | ||
time_angle = tmp_packet.stamp; | ||
} | ||
|
||
if((last_azimuth_ < config_.cut_angle && config_.cut_angle <= azimuth) | ||
|| ( config_.cut_angle <= azimuth && azimuth < last_azimuth_) | ||
|| (azimuth < last_azimuth_ && last_azimuth_ < config_.cut_angle)) | ||
|
@@ -270,6 +305,9 @@ bool VelodyneDriver::poll(void) | |
if (config_.timestamp_first_packet){ | ||
scan->header.stamp = scan->packets.front().stamp; | ||
} | ||
else if(config_.timestamp_angle >= 0.0){ | ||
scan->header.stamp = time_angle; | ||
} | ||
else{ | ||
scan->header.stamp = scan->packets.back().stamp; | ||
} | ||
|
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.
Could you please include a description somewhere of what this actually means/does? It's definitely unclear to me.