-
Notifications
You must be signed in to change notification settings - Fork 14
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
Connector: IssacSim -> Ignition #16
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c90eea6
Connector: IssacSim -> Ignition
ahcorde c5d1fc1
Merge remote-tracking branch 'origin/main' into ahcorde/issacsim_2_ig…
ahcorde ffdd1f0
Added feedback
ahcorde f858a4d
Workaround model sync (#19)
7edfc7d
Added some fixes
ahcorde 91f76eb
Some fixes
ahcorde 24dc155
Joints
ahcorde e7bc26c
improve joint and whem we should add a link or visual
ahcorde d572087
include some improvements
ahcorde b23402e
Improve implemenetation
ahcorde 5ac2ab0
Added feedback
ahcorde 78e43db
Merge remote-tracking branch 'origin/main' into ahcorde/issacsim_2_ig…
ahcorde c9f346a
Fix joint issue
ahcorde 4d6daa0
Restructure tutorials
ahcorde e952b99
Fix some issues
ahcorde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,8 @@ class FUSDNoticeListener::Implementation | |
|
||
std::mutex jointStateMsgMutex; | ||
std::unordered_map<std::string, double> jointStateMap; | ||
|
||
std::unordered_map<std::string, uint32_t> * entitiesByName; | ||
}; | ||
|
||
void FUSDNoticeListener::Implementation::ParseCube( | ||
|
@@ -131,9 +133,6 @@ void FUSDNoticeListener::Implementation::ParseSphere( | |
auto variant_sphere = pxr::UsdGeomSphere(_prim); | ||
variant_sphere.GetRadiusAttr().Get(&radius); | ||
|
||
// By default isaac sim uses millimeters | ||
radius *= 0.01; | ||
|
||
sdf::Visual visual; | ||
sdf::Collision collision; | ||
sdf::Geometry geom; | ||
|
@@ -153,14 +152,16 @@ void FUSDNoticeListener::Implementation::ParseSphere( | |
} | ||
|
||
FUSDNoticeListener::FUSDNoticeListener( | ||
std::shared_ptr<ThreadSafe<pxr::UsdStageRefPtr>> _stage, | ||
std::shared_ptr<ThreadSafe<pxr::UsdStageRefPtr>> &_stage, | ||
const std::string &_worldName, | ||
Simulator _simulatorPoses) | ||
Simulator _simulatorPoses, | ||
std::unordered_map<std::string, uint32_t> &_entitiesByName) | ||
: dataPtr(ignition::utils::MakeUniqueImpl<Implementation>()) | ||
{ | ||
this->dataPtr->stage = _stage; | ||
this->dataPtr->worldName = _worldName; | ||
this->dataPtr->simulatorPoses = _simulatorPoses; | ||
this->dataPtr->entitiesByName = &_entitiesByName; | ||
|
||
std::string jointStateTopic = "/joint_states"; | ||
|
||
|
@@ -174,7 +175,7 @@ void FUSDNoticeListener::Implementation::jointStateCb( | |
const ignition::msgs::Model &_msg) | ||
{ | ||
std::lock_guard<std::mutex> lock(this->jointStateMsgMutex); | ||
for(int i = 0 ; i < _msg.joint_size();++i) | ||
for(int i = 0; i < _msg.joint_size(); ++i) | ||
{ | ||
this->jointStateMap[_msg.joint(i).name()] = | ||
_msg.joint(i).axis1().position(); | ||
|
@@ -184,10 +185,11 @@ void FUSDNoticeListener::Implementation::jointStateCb( | |
void FUSDNoticeListener::Handle( | ||
const class pxr::UsdNotice::ObjectsChanged &ObjectsChanged) | ||
{ | ||
auto stage = this->dataPtr->stage->Lock(); | ||
|
||
for (const pxr::SdfPath &objectsChanged : ObjectsChanged.GetResyncedPaths()) | ||
{ | ||
ignmsg << "Resynced Path: " << objectsChanged.GetText() << std::endl; | ||
auto stage = this->dataPtr->stage->Lock(); | ||
auto modelUSD = stage->GetPrimAtPath(objectsChanged); | ||
std::string primName = modelUSD.GetName(); | ||
|
||
|
@@ -199,12 +201,27 @@ void FUSDNoticeListener::Handle( | |
|
||
if (modelUSD) | ||
{ | ||
// std::string strPath = objectsChanged.GetText(); | ||
// if (strPath.find("_link") != std::string::npos | ||
// || strPath.find("_visual") != std::string::npos | ||
// || strPath.find("geometry") != std::string::npos) { | ||
// return; | ||
// } | ||
std::string strPath = objectsChanged.GetText(); | ||
if (strPath.find("_link") != std::string::npos | ||
|| strPath.find("_visual") != std::string::npos | ||
|| strPath.find("geometry") != std::string::npos) { | ||
return; | ||
} | ||
|
||
auto it = this->dataPtr->entitiesByName->find(modelUSD.GetName().GetString()); | ||
if (it != this->dataPtr->entitiesByName->end()) | ||
{ | ||
continue; | ||
} | ||
|
||
auto range = pxr::UsdPrimRange::Stage(*stage); | ||
for (auto const &prim : range) | ||
{ | ||
if (prim.GetName().GetString() == primName) | ||
{ | ||
continue; | ||
} | ||
} | ||
|
||
sdf::Root root; | ||
|
||
|
@@ -259,7 +276,6 @@ void FUSDNoticeListener::Handle( | |
// this loop checks all paths to find revolute joints | ||
// if there is some, we get the body0 and body1 and calculate the | ||
// joint angle. | ||
auto stage = this->dataPtr->stage->Lock(); | ||
auto range = pxr::UsdPrimRange::Stage(*stage); | ||
{ | ||
std::lock_guard<std::mutex> lock(this->dataPtr->jointStateMsgMutex); | ||
|
@@ -295,7 +311,6 @@ void FUSDNoticeListener::Handle( | |
{ | ||
if (std::string(objectsChanged.GetText()) == "/") | ||
continue; | ||
auto stage = this->dataPtr->stage->Lock(); | ||
igndbg << "path " << objectsChanged.GetText() << std::endl; | ||
auto modelUSD = stage->GetPrimAtPath(objectsChanged.GetParentPath()); | ||
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. Wasn't able to test this as I can't get the panda sim working. My only guess for joints orientation is that maybe the pose is being applied twice, first when calculating the joints position and then again here when calculating the pose? |
||
auto property = modelUSD.GetPropertyAtPath(objectsChanged); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I guess this fixed the double lock issue? Not sure why that happens and how this fixes it, I guess the mutex got copied for some reason?