ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

URDF/RobotModel + joint states to tf robot states in a function call?

asked 2022-07-24 10:48:28 -0500

lucasw gravatar image

updated 2022-07-24 11:23:10 -0500

Is there a way to get all the functionality of robot_state_publisher in a function call? I want to be able to get transforms within a robot model given hypothetical joint positions in a fast loop, so it can't listen to joint state topics or publish onto /tf.

robot_model.init(urdf_from_robot_description_rosparam_or_xml_string)
transforms = robot_model.update(new_joint_states)
... put transforms into a BufferCore and then can do tf lookups

I was hoping I could do this in python maybe with urdf_parser_py, but if not I'll use C++ instead and refactor robot_state_publisher so I can provide joint states directly and return transforms instead of having a listener and publisher. But it would be nice to save that effort- does moveit provide something similar without going through any planning or IK, just jumps to set angles?

https://answers.ros.org/question/3789... is maybe asking half of the same question but specific to moveit, https://answers.ros.org/question/2501... is also similar

https://answers.ros.org/answers/20916... says it isn't possible (as of 2015)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-24 19:07:33 -0500

lucasw gravatar image

https://github.com/lucasw/robot_state... has code cut-and-paste out of robot_state_publisher into a standalone RobotState class, and https://github.com/lucasw/robot_state... shows basic usage.

#include <robot_state_publisher/robot_state.h>
...
robot_state_publisher::RobotState rs;
const auto stamp = ros::Time::now();    
sensor_msgs::JointState js;
js.header.stamp = stamp;
js.name.push_back("joint1");
double angle = 0.538;
js.position.push_back(angle);
rs.setJointState(js);    
const tf2_msgs::TFMessage tfm = rs.getTransforms(stamp);
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-07-24 10:48:28 -0500

Seen: 41 times

Last updated: Jul 24 '22