-
Notifications
You must be signed in to change notification settings - Fork 61
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/lidar lite #3
base: master
Are you sure you want to change the base?
Changes from 3 commits
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
1.1.0 (TBD) | ||
------------------ | ||
* Add Lidar Lite sensor | ||
|
||
1.0.0 (2019-12-09) | ||
------------------ | ||
|
||
First public *stable* release | ||
|
||
Accompanies our paper submission Tschopp, Florian, et al. "VersaVIS: An Open Versatile Multi-Camera Visual-Inertial Sensor Suite." arXiv preprint arXiv:1912.02469 (2019). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "LidarLite.h" | ||
|
||
#include "helper.h" | ||
#include "versavis_configuration.h" | ||
|
||
LidarLite::LidarLite(ros::NodeHandle *nh, const String &topic, | ||
const int rate_hz, Timer &timer) | ||
: Sensor(nh, topic, rate_hz, timer, range_msg_) {} | ||
|
||
void LidarLite::setup() { | ||
// The LidarEnhanced driver will configure this GPIO to start/stop the | ||
// LidarLite. We map it on an unused pins. | ||
const int kLidarEnablePin = 19; // Not connected. | ||
lidar_.begin(kLidarEnablePin); | ||
const bool kFastI2C = true; | ||
lidar_controller_.begin(kFastI2C); | ||
delay(100); | ||
lidar_controller_.add(&lidar_, kId); | ||
setupPublisher(); | ||
} | ||
|
||
void LidarLite::begin() { | ||
DEBUG_PRINTLN((topic_ + " (LidarLite.cpp): Begin.").c_str()); | ||
Sensor::setupTimer(); | ||
} | ||
|
||
void LidarLite::triggerMeasurement() { | ||
// Check whether an overflow caused the interrupt. | ||
if (!timer_.checkOverflow()) { | ||
DEBUG_PRINTLN( | ||
(topic_ + " (LidarLite.cpp): Timer interrupt but not overflown.") | ||
.c_str()); | ||
return; | ||
} | ||
|
||
DEBUG_PRINTLN((topic_ + " (LidarLite.cpp): Trigger.").c_str()); | ||
Sensor::newMeasurementIsAvailable(); | ||
// Reset the timer. | ||
timer_.resetOverflow(); | ||
} | ||
|
||
void LidarLite::publish() { | ||
if (Sensor::isNewMeasurementAvailable()) { | ||
// Get the most recent time stamp. | ||
range_msg_.time.data = Sensor::getTimestamp(); | ||
|
||
// Get signal strength. | ||
uint8_t nack = | ||
lidar_controller_.signalStrength(kId, &range_msg_.signal_strength); | ||
if (nack) { | ||
Sensor::newMeasurementIsNotAvailable(); | ||
return; | ||
} | ||
|
||
// Get range and trigger new measurement. | ||
nack = lidar_controller_.distanceAndAsync(kId, &range_msg_.range); | ||
// New measurement triggered. Set the next time stamp. | ||
Sensor::setTimestampNow(); | ||
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. You need to set the timestamp before writing it to the message header (Line 45) for this specific measurement (e.g. at the very beginning of |
||
if (nack) { | ||
Sensor::newMeasurementIsNotAvailable(); | ||
return; | ||
} | ||
|
||
if (range_msg_.time.data.sec != 0 && range_msg_.time.data.nsec != 0) { | ||
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 assume this is a catch for the very first measurement. If you adapt my suggestion above, this should not happen anymore. |
||
#ifndef DEBUG | ||
publisher_.publish(&range_msg_); | ||
#endif | ||
} | ||
|
||
Sensor::newMeasurementIsNotAvailable(); | ||
} | ||
} | ||
|
||
void LidarLite::setupPublisher() { | ||
publisher_ = ros::Publisher(topic_.c_str(), &range_msg_); | ||
DEBUG_PRINT( | ||
(topic_ + " (LidarLite.cpp): Setup publisher with topic ").c_str()); | ||
DEBUG_PRINTLN(publisher_.topic_); | ||
#ifndef DEBUG | ||
nh_->advertise(publisher_); | ||
#endif | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// December 2019 | ||
// Author: Rik Bähnemann <brik@ethz.ch> | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// LidarLite.h | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Implementation for Garmin Lidar Lite in the versavis framework. Refer to the | ||
// parent package versavis for license information. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef LidarLite_h | ||
#define LidarLite_h | ||
|
||
#include <LidarController.h> | ||
#include <LidarObject.h> | ||
#include <Sensor.h> | ||
#include <versavis/RangeMicro.h> | ||
|
||
class LidarLite : public Sensor { | ||
public: | ||
LidarLite(ros::NodeHandle *nh, const String &topic, const int rate_hz, | ||
Timer &timer); | ||
void setup() override; | ||
void begin() override; | ||
void triggerMeasurement() override; | ||
void publish() override; | ||
void setupPublisher() override; | ||
|
||
private: | ||
// Disable copy / assignment constructors. | ||
LidarLite(const LidarLite &) = delete; | ||
LidarLite &operator=(const LidarLite &) = delete; | ||
|
||
const uint8_t kId = 0; | ||
|
||
versavis::RangeMicro range_msg_; | ||
|
||
LidarController lidar_controller_; | ||
LidarObject lidar_; | ||
}; | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0"?> | ||
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. Could you rename this to |
||
|
||
<launch> | ||
<!-- Run arduino link. --> | ||
<node name="rosserial_python" pkg="rosserial_python" type="serial_node.py" | ||
args="_port:=/dev/ttyACM0 _baud:=250000" required="true" output="screen" /> | ||
|
||
<!-- Receiver Lidar Lite message. --> | ||
<node name="versavis_lidar_lite_receiver" pkg="versavis" | ||
type="versavis_range_receiver" required="true" output="screen"> | ||
<param name="range_sub_topic" value="/versavis/lidar_lite_micro" /> | ||
<param name="range_pub_topic" value="/versavis/lidar_lite" /> | ||
|
||
<!-- Parameters from Garmin Lidar Lite v3 specs. --> | ||
<!-- https://buy.garmin.com/en-US/US/p/557294#specs --> | ||
<param name="frame_id" value="lidar_lite" /> | ||
<param name="radiation_type" value="1" /> <!-- 1 = INFRARED --> | ||
<param name="field_of_view" value="0.008" /> | ||
<param name="min_range" value="0.05" /> | ||
<param name="max_range" value="40.0" /> | ||
<param name="range_sensitivity" value="0.01" /> | ||
<param name="min_signal_strength" value="0" /> <!-- No minimum signal strength --> | ||
</node> | ||
|
||
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. Maybe add a comment here to force-initialize the cameras. |
||
<node pkg="rostopic" type="rostopic" name="initializer_cam0" args="pub -r 10 /versavis/cam0/init std_msgs/Bool {'data: True'}"/> | ||
|
||
<node pkg="rostopic" type="rostopic" name="initializer_cam1" args="pub -r 10 /versavis/cam1/init std_msgs/Bool {'data: True'}"/> | ||
|
||
<node pkg="rostopic" type="rostopic" name="initializer_cam2" args="pub -r 10 /versavis/cam2/init std_msgs/Bool {'data: True'}"/> | ||
</launch> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This is a super-minimized message to hold data from a range sensor, such as Garmin LidarLite. | ||
# | ||
# Ranges and signal strengths are raw data and have to be scaled! | ||
# | ||
# To minimize the amount of data transfered by this message (e.g. form an Arduino through rosserial) | ||
# the amount of data is truncated to its absolute minimum. | ||
|
||
std_msgs/Time time | ||
|
||
int16 range | ||
uint8 signal_strength |
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.
both mentioned PRs got merged, we could switch to main repo