Skip to content
Snippets Groups Projects
Commit b453cdc7 authored by Fabian Paus's avatar Fabian Paus
Browse files

Hokuyo: Added angle offset

parent c50a6037
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ void HokuyoLaserUnit::onInitComponent() ...@@ -35,6 +35,7 @@ void HokuyoLaserUnit::onInitComponent()
topicName = getProperty<std::string>("LaserScannerTopicName").getValue(); topicName = getProperty<std::string>("LaserScannerTopicName").getValue();
offeringTopic(topicName); offeringTopic(topicName);
updatePeriod = getProperty<int>("UpdatePeriod").getValue(); updatePeriod = getProperty<int>("UpdatePeriod").getValue();
angleOffset = getProperty<float>("AngleOffset").getValue();
std::string deviceStrings = getProperty<std::string>("Devices").getValue(); std::string deviceStrings = getProperty<std::string>("Devices").getValue();
std::vector<std::string> splitDeviceStrings; std::vector<std::string> splitDeviceStrings;
...@@ -147,7 +148,7 @@ void HokuyoLaserUnit::updateScanData() ...@@ -147,7 +148,7 @@ void HokuyoLaserUnit::updateScanData()
for (int stepIndex = 0; stepIndex < lengthDataSize; ++stepIndex) for (int stepIndex = 0; stepIndex < lengthDataSize; ++stepIndex)
{ {
LaserScanStep step; LaserScanStep step;
step.angle = float(0.25 * M_PI / 180.0 * stepIndex); step.angle = angleOffset + float(0.25 * M_PI / 180.0 * stepIndex);
step.distance = lengthDataSize * stepIndex / 100.0f + 200.0f; step.distance = lengthDataSize * stepIndex / 100.0f + 200.0f;
scan.push_back(step); scan.push_back(step);
} }
...@@ -179,8 +180,7 @@ void HokuyoLaserUnit::updateScanData() ...@@ -179,8 +180,7 @@ void HokuyoLaserUnit::updateScanData()
for (int stepIndex = 0; stepIndex < lengthDataSize; ++stepIndex) for (int stepIndex = 0; stepIndex < lengthDataSize; ++stepIndex)
{ {
LaserScanStep step; LaserScanStep step;
// TODO: We need an angle offset for the sensor step.angle = angleOffset + (float)urg_step2rad(&device.urg, stepIndex); // Convert steps to rad
step.angle = (float)urg_step2rad(&device.urg, stepIndex); // Convert steps to rad
step.distance = (float)device.lengthData[stepIndex]; // Data is already in mm step.distance = (float)device.lengthData[stepIndex]; // Data is already in mm
scan.push_back(step); scan.push_back(step);
} }
......
...@@ -46,6 +46,7 @@ namespace armarx ...@@ -46,6 +46,7 @@ namespace armarx
{ {
defineOptionalProperty<std::string>("LaserScannerTopicName", "LaserScans", "Name of the laser scan topic."); defineOptionalProperty<std::string>("LaserScannerTopicName", "LaserScans", "Name of the laser scan topic.");
defineOptionalProperty<int>("UpdatePeriod", 25, "Update period for laser scans"); defineOptionalProperty<int>("UpdatePeriod", 25, "Update period for laser scans");
defineOptionalProperty<float>("AngleOffset", -2.3561944902, "Offset is applied the raw angles before reporting them");
defineOptionalProperty<std::string>("Devices", "", "List of devices in form of 'IP1,port1;IP2,port2;...'"); defineOptionalProperty<std::string>("Devices", "", "List of devices in form of 'IP1,port1;IP2,port2;...'");
} }
}; };
...@@ -117,6 +118,7 @@ namespace armarx ...@@ -117,6 +118,7 @@ namespace armarx
std::string topicName; std::string topicName;
LaserScannerUnitListenerPrx topic; LaserScannerUnitListenerPrx topic;
int updatePeriod = 25; int updatePeriod = 25;
float angleOffset = 0.0f;
std::vector<HokuyoLaserScanDevice> devices; std::vector<HokuyoLaserScanDevice> devices;
PeriodicTask<HokuyoLaserUnit>::pointer_type task; PeriodicTask<HokuyoLaserUnit>::pointer_type task;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment