Skip to content

Commit

Permalink
Adding the joint type to the properties shown
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Wagner <[email protected]>
  • Loading branch information
WagnerMarcos committed Jul 1, 2021
1 parent f4a3b07 commit bc3d437
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions model/src/ModelCommandAPI_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,19 @@ TEST(ModelCommandAPI, Commands)
" - Joint [21]\n"
" - Name: left_wheel_joint\n"
" - Parent: vehicle_blue [8]\n"
" - Joint type: revolute\n"
" - Parent Link: [left_wheel]\n"
" - Child Link: [chassis]\n"
" - Joint [22]\n"
" - Name: right_wheel_joint\n"
" - Parent: vehicle_blue [8]\n"
" - Joint type: revolute\n"
" - Parent Link: [right_wheel]\n"
" - Child Link: [chassis]\n"
" - Joint [23]\n"
" - Name: caster_wheel\n"
" - Parent: vehicle_blue [8]\n"
" - Joint type: ball\n"
" - Parent Link: [caster]\n"
" - Child Link: [chassis]\n";
EXPECT_EQ(expectedOutput, non_neg_zero_output);
Expand Down Expand Up @@ -285,16 +288,19 @@ TEST(ModelCommandAPI, Commands)
" - Joint [21]\n"
" - Name: left_wheel_joint\n"
" - Parent: vehicle_blue [8]\n"
" - Joint type: revolute\n"
" - Parent Link: [left_wheel]\n"
" - Child Link: [chassis]\n"
" - Joint [22]\n"
" - Name: right_wheel_joint\n"
" - Parent: vehicle_blue [8]\n"
" - Joint type: revolute\n"
" - Parent Link: [right_wheel]\n"
" - Child Link: [chassis]\n"
" - Joint [23]\n"
" - Name: caster_wheel\n"
" - Parent: vehicle_blue [8]\n"
" - Joint type: ball\n"
" - Parent Link: [caster]\n"
" - Child Link: [chassis]\n";
EXPECT_EQ(expectedOutput, non_neg_zero_output);
Expand All @@ -312,6 +318,7 @@ TEST(ModelCommandAPI, Commands)
" - Joint [23]\n"
" - Name: caster_wheel\n"
" - Parent: vehicle_blue [8]\n"
" - Joint type: ball\n"
" - Parent Link: [caster]\n"
" - Child Link: [chassis]\n";
EXPECT_EQ(expectedOutput, non_neg_zero_output);
Expand Down
18 changes: 17 additions & 1 deletion model/src/cmd/ModelCommandAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <string>
#include <vector>
#include <map>

#include <ignition/common/Console.hh>
#include <ignition/common/Filesystem.hh>
Expand Down Expand Up @@ -279,14 +280,29 @@ void printJoints(uint64_t entity,
}
{

std::map<sdf::JointType, std::string> jointTypes = {
{sdf::JointType::REVOLUTE, "revolute"},
{sdf::JointType::BALL, "ball"},
{sdf::JointType::CONTINUOUS, "continuous"},
{sdf::JointType::FIXED, "fixed"},
{sdf::JointType::GEARBOX, "gearbox"},
{sdf::JointType::PRISMATIC, "prismatic"},
{sdf::JointType::REVOLUTE2, "revolute2"},
{sdf::JointType::SCREW, "screw"},
{sdf::JointType::UNIVERSAL, "universal"}
};

auto jointComp =
ecm.Component<ignition::gazebo::components::JointType>(_entity);
auto childLinkComp =
ecm.Component<ignition::gazebo::components::ChildLinkName>(_entity);
auto parentLinkComp =
ecm.Component<ignition::gazebo::components::ParentLinkName>(_entity);

if (childLinkComp && parentLinkComp)
{
std::cout << " - Parent Link: [" << childLinkComp->Data() << "]\n"
std::cout << " - Joint type: " << jointTypes[jointComp->Data()] << "\n"
<< " - Parent Link: [" << childLinkComp->Data() << "]\n"
<< " - Child Link: [" << parentLinkComp->Data() << "]\n";
}
}
Expand Down

0 comments on commit bc3d437

Please sign in to comment.