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

Enhancement/pose estimator #497

Merged
merged 29 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e2440aa
Pose estimator enhancement
gilwoolee Jan 27, 2019
da1b722
Add cpp classes in perception
gilwoolee Jan 27, 2019
e27ecaf
clean up hancks for demo
yskim041 Jan 27, 2019
fb1bfc0
update CHANGELOG.md
yskim041 Jan 27, 2019
61a3a24
add a new class DetectedObject and update PoseEstimatorModule
yskim041 Feb 3, 2019
853e11b
minor fixes
yskim041 Feb 3, 2019
f8c7758
Merge branch 'master' into enhancement/pose_estimator
brianhou Feb 3, 2019
4ce2f50
remove the projection height from PoseEstimatorModule
yskim041 Feb 3, 2019
e84d6fd
Merge branch 'enhancement/pose_estimator' of https://github.com/perso…
yskim041 Feb 3, 2019
e874ec9
Merge branch 'master' into enhancement/pose_estimator
brianhou Feb 3, 2019
286359d
document DetectedObject class
yskim041 Feb 4, 2019
062f16f
change 'id' -> 'uid'
yskim041 Feb 4, 2019
4b08f35
Update include/aikido/perception/DetectedObject.hpp
gilwoolee Feb 5, 2019
1ce5724
Update include/aikido/perception/DetectedObject.hpp
gilwoolee Feb 5, 2019
3ac8326
Update include/aikido/perception/DetectedObject.hpp
gilwoolee Feb 5, 2019
b03e20f
Merge branch 'master' into enhancement/pose_estimator
gilwoolee Feb 11, 2019
cc58f6b
change the way to parse a Marker message
yskim041 Feb 12, 2019
c973cc0
Allow nullptr for detectedObjects argument
egordon Feb 12, 2019
bc3bf1b
Added robustness against bad YAML strings, plus more easily-parse-abl…
egordon Feb 12, 2019
527e462
Fixed documentation per comments, tested with simple_perception in ad…
egordon Feb 13, 2019
1633676
Added default argument to detectedObjects.
egordon Feb 13, 2019
9732051
Fixed comments on pull request
egordon Feb 13, 2019
36d422e
Indigo compatibility (no DELETEALL)
egordon Feb 13, 2019
7c3971a
Apply suggestions from code review
brianhou Feb 13, 2019
79f921a
Applied comments from PR review: refactored ObjectDatabase to AssetDa…
egordon Feb 13, 2019
af32515
Clang formatted
egordon Feb 13, 2019
9581880
Fixed PR comments.
egordon Feb 14, 2019
21460a9
Move vector push to end of for loop
egordon Feb 14, 2019
92fa686
Final PR nits.
egordon Feb 14, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

* Added integrated PoseEstimatorModule: [#336](https://github.com/personalrobotics/aikido/pull/336)
* Added voxel grid perception module: [#448](https://github.com/personalrobotics/aikido/pull/448)
* Added YAML communication between PoseEstimatorModule and third party perception algorithms: [#497](https://github.com/personalrobotics/aikido/pull/497)
egordon marked this conversation as resolved.
Show resolved Hide resolved

* Trajectory

Expand Down
2 changes: 1 addition & 1 deletion include/aikido/perception/ObjectDatabase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace perception {
/// Here is an example entry in a JSON file:
/// \code
/// "obj_key": {
/// "resource": "package://pr_ordata/data/objects/obj_filename.urdf",
/// "resource": "package://pr_assets/data/objects/obj_filename.urdf",
/// "name": "obj_name",
/// "offset": [
/// [1.0, 0.0, 0.0, 0.0],
Expand Down
18 changes: 18 additions & 0 deletions include/aikido/perception/PoseEstimatorModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <ros/ros.h>
#include <tf/transform_listener.h>
#include "aikido/io/CatkinResourceRetriever.hpp"
#include "aikido/io/yaml.hpp"
#include "aikido/perception/ObjectDatabase.hpp"
#include "aikido/perception/PerceptionModule.hpp"

Expand Down Expand Up @@ -54,6 +55,17 @@ class PoseEstimatorModule : public PerceptionModule
ros::Duration timeout = ros::Duration(0.0),
egordon marked this conversation as resolved.
Show resolved Hide resolved
ros::Time timestamp = ros::Time(0.0)) override;

/// Getter for \c mObjInfo. \c mObjInfo is saving additional information
yskim041 marked this conversation as resolved.
Show resolved Hide resolved
/// from the text field in the MarkerArray message in json format.
/// This getter returns a YAML::Node of an object by id.
///
/// \param[in] obj_id The key of an object to retrieve its additional
/// information
YAML::Node getObjInfo(const std::string& obj_id);
yskim041 marked this conversation as resolved.
Show resolved Hide resolved

/// If this is set, all objects are projected to this height.
void setObjectProjectionHeight(double projectionHeight);

private:
/// For the ROS node that will work with the April Tags module
ros::NodeHandle mNodeHandle;
Expand All @@ -75,6 +87,12 @@ class PoseEstimatorModule : public PerceptionModule

/// Listens to the transform attached to the node
tf::TransformListener mTfListener;

/// For additional information for each object
yskim041 marked this conversation as resolved.
Show resolved Hide resolved
std::unordered_map<std::string, YAML::Node> mObjInfo;

bool mProjectObjectToFixedHeight;
yskim041 marked this conversation as resolved.
Show resolved Hide resolved
double mProjectionHeight;
};

} // namespace perception
Expand Down
3 changes: 2 additions & 1 deletion src/perception/ObjectDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void ObjectDatabase::getObjectByKey(
YAML::Node objectNode = mObjData[objectKey];
if (!objectNode)
{
throw std::runtime_error("[ObjectDatabase] Error: invalid object key");
throw std::runtime_error(
"[ObjectDatabase] Error: invalid object key: " + objectKey);
}

// Convert resource field
Expand Down
34 changes: 32 additions & 2 deletions src/perception/PoseEstimatorModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <ros/topic.h>
#include <visualization_msgs/Marker.h>
#include <visualization_msgs/MarkerArray.h>
#include <yaml-cpp/exceptions.h>
yskim041 marked this conversation as resolved.
Show resolved Hide resolved
#include "aikido/io/CatkinResourceRetriever.hpp"
#include "aikido/perception/shape_conversions.hpp"

Expand All @@ -27,6 +28,8 @@ PoseEstimatorModule::PoseEstimatorModule(
, mReferenceFrameId(std::move(referenceFrameId))
, mReferenceLink(std::move(referenceLink))
, mTfListener(mNodeHandle)
, mProjectObjectToFixedHeight(false)
, mProjectionHeight(0.0)
{
// Do nothing
}
Expand Down Expand Up @@ -64,14 +67,18 @@ bool PoseEstimatorModule::detectObjects(
for (const auto& marker_transform : marker_message->markers)
{
const auto& marker_stamp = marker_transform.header.stamp;
const auto& obj_key = marker_transform.text;
const auto& obj_id = marker_transform.ns;
const auto& obj_key = marker_transform.ns;
const auto& detection_frame = marker_transform.header.frame_id;
if (!timestamp.isValid() || marker_stamp < timestamp)
{
continue;
}

YAML::Node info_json = YAML::Load(marker_transform.text);
const std::string obj_id = info_json["id"].as<std::string>();

mObjInfo.insert(std::make_pair(obj_id, info_json));

// If obj_key is "None",
// remove a skeleton with obj_id from env
// and move to next marker
Expand Down Expand Up @@ -122,6 +129,11 @@ bool PoseEstimatorModule::detectObjects(
Eigen::Isometry3d link_offset = mReferenceLink->getWorldTransform();
obj_pose = link_offset * obj_pose;

if (mProjectObjectToFixedHeight)
{
obj_pose.translation()[2] = mProjectionHeight;
}

bool is_new_obj;
dart::dynamics::SkeletonPtr obj_skeleton;

Expand Down Expand Up @@ -195,5 +207,23 @@ bool PoseEstimatorModule::detectObjects(
return true;
}

YAML::Node PoseEstimatorModule::getObjInfo(const std::string& obj_id)
yskim041 marked this conversation as resolved.
Show resolved Hide resolved
{
YAML::Node targetNode = mObjInfo[obj_id];
if (!targetNode)
{
throw std::runtime_error(
"[PoseEstimatorModule::getObjInfo] Error: invalid obj_id");
}

return targetNode;
}

void PoseEstimatorModule::setObjectProjectionHeight(double projectionHeight)
yskim041 marked this conversation as resolved.
Show resolved Hide resolved
{
mProjectObjectToFixedHeight = true;
mProjectionHeight = projectionHeight;
}

} // namespace perception
} // namespace aikido