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

KDL based Movement in Cartesian Space #167

Merged

Conversation

BoWangFromMars
Copy link
Contributor

KDL(Kinematics and Dynamics Library) installation process is introduced in this branch. Based on forward kinematics and inverse kinematics provided by KDL, a demo, which makes the robot move in z axis in Cartesian space, is added in this branch. Please see the detailed information in pdf file "KDL installation and demo.pdf" in the directory './lbr_demos_fri_ros2_cpp/doc'.

 tutorial of KDL installation and demo of Cartesian space movement based on KDL, including forward kinematics and inverse kinematics based on KDL
This demo, based on forward kinematics and inverse kinematics provided by KDL, makes the robot move in z axis in Cartesian space. About how to run this demo, please refer to 'KDL installation and demo.pdf' in the directory './lbr_demos_fri_ros2_cpp/doc/KDL installation and demo.pdf'.
@mhubii
Copy link
Member

mhubii commented Apr 11, 2024

thank you for the PR @BoWangFromMars. I would create a development branch so you can re-target the PR against this branch. Then I can make some modifications to the PR on the dev branch.

@BoWangFromMars BoWangFromMars changed the base branch from humble to dev-humble-cart-vel-demo April 13, 2024 10:25
Copy link
Member

@mhubii mhubii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed your PR. Could you please amend changes. Not all suggestions might make sense, so feel free to keep things that make sense to you

phase_ = 0.0;
count_= 0.0;

std::string urdf_file_path = "/home/nearlab-iiwa/lbr-stack/src/lbr_fri_ros2_stack/lbr_description/urdf/iiwa7/my_iiwa7.urdf"; // path of your robot urdf file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to load this from the /robot_description parameter instead

{
current_robot_state = msg;

if(count_ < 200) // in first 2 seconds, to make 'initial_position_command' be 'measured_joint_position'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to introduce is_init bool or turn current_robot_state into unique pointer and check for null

KDL::JntArray result_joint_positions = KDL::JntArray(chain.getNrOfJoints());
lbr_fri_msgs::msg::LBRPositionCommand joint_position_command;

auto start = std::chrono::high_resolution_clock::now();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe only measure time on debug

{
KDL::Frame cartesian_position_command = initial_cartesian_position;

cartesian_position_command.p = KDL::Vector(initial_cartesian_position.p.x(), initial_cartesian_position.p.y(), initial_cartesian_position.p.z() + amplitude_ * sin(phase_));
Copy link
Member

@mhubii mhubii Apr 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh okay I see, this performs oscillation in Cartesian space, could you maybe add a Cartesian pose topic or even better a Twist topic (to indicate velocity commands) instead? Twist commands might need some code changes

The function of this node is to publish Cartesian Pose state of the robot and receive Cartesian Pose Command from other ros nodes.
This file introduces how to install KDL(kinematics and dynamics library) in our system and a demo based on it is given to make the robot run in z direction in Cartesian space.
This node publishes Cartesian Pose command.
This node, as a demo, publishes Cartesian Pose command to make the robot run in z direction in Cartesian space.
This node publishes Cartesian Pose state of the robot and receives Cartesian Pose command from other ros nodes, and transform it into joint positions based on KDL to send to the robot.
@mhubii
Copy link
Member

mhubii commented Apr 17, 2024

so ideally the robot descriptions will be loaded from the /robot_description topic, and there is no need for the additional .urdf files. Hope that makes sense. Alternatively, the robot description could be parsed as a parameter to the node.

From Topic

Create subscription to /robot_description. robot_state_publisher publishes the robot description with QoS transient local topic, see e.g. https://docs.ros.org/en/rolling/Concepts/Intermediate/About-Quality-of-Service-Settings.html:

  • Durability
    • Transient local: the publisher becomes responsible for persisting samples for “late-joining” subscriptions.

From Parameter

Refer e.g.

this->declare_parameter<std::string>("robot_description");

@@ -0,0 +1,229 @@
<?xml version="1.0" ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these files are redundant


// get the path of urdf file
std::filesystem::path current_working_directory = std::filesystem::current_path();
std::string urdf_file_path = current_working_directory.string()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting the current path might not work in general

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @mhubii, thank you very much for your suggestion and QoS documentation, I learn a lot from it. I modify my code following your advice today and then upload it again after I test it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, happy to merge once the /robot_description is loaded from topic / parameter and .urdf files are removed

Copy link
Member

@mhubii mhubii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more dependency hints

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more question regarding this doc. KDL is usually installed through rosdep as listed in package.xml files, refer e.g.

<depend>urdf</depend>
<depend>geometry_msgs</depend>
<depend>sensor_msgs</depend>
<depend>orocos_kdl</depend>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this dependency should be replaced by orocos_kdl_vendor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I get it, thank you.

@mhubii mhubii merged commit b6fd909 into lbr-stack:dev-humble-cart-vel-demo Apr 22, 2024
@mhubii mhubii mentioned this pull request Apr 22, 2024
6 tasks
@mhubii
Copy link
Member

mhubii commented Apr 22, 2024

thank you again for the PR @BoWangFromMars. I merged this into the dev branch and will update in #170.

If you want to make amend changes yourself, please add a PR to the dev branch again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants