3 #include <sensor_msgs/JointState.h>
22 : robot_(
robot), base_(base_frame), nh_(
"/" + name)
24 state_pub_ =
nh_.advertise<sensor_msgs::JointState>(
"/joint_states", 1);
32 ros::WallDuration pause(1. / rate_);
47 ros::WallDuration pause(1. / rate_);
63 if (static_.find(name) == static_.end())
70 static_.emplace(name, stf);
73 RBX_ERROR(
"Static transform %s already in map!", name);
78 auto it = static_.find(name);
79 if (it != static_.end())
82 RBX_ERROR(
"Static transform %s does not exist in map!", name);
87 const auto &state = robot_->getScratchStateConst();
88 const auto &model = robot_->getModelConst();
90 for (
const auto &link : model->getLinkModels())
92 const auto &parent = link->getParentLinkModel();
95 link->getJointOriginTransform() * state->getJointTransform(link->getParentJointModel());
97 std::string source = (parent) ? parent->getName() : base_;
102 tf2br_.sendTransform(msg);
105 for (
const auto &pair : static_)
107 const auto &stf = pair.second;
109 tf2br_.sendTransform(static_msg);
112 unsigned int n = state->getVariableCount();
114 sensor_msgs::JointState msg;
115 msg.header.stamp = ros::Time::now();
116 msg.name = state->getVariableNames();
118 arrayToVector(state->getVariablePositions(), n, msg.position);
119 arrayToVector(state->getVariableVelocities(), n, msg.velocity);
120 arrayToVector(state->getVariableEffort(), n, msg.effort);
122 state_pub_.publish(msg);
void addStaticTransform(const std::string &name, const std::string &base, const std::string &target, const RobotPose &tf=RobotPose::Identity())
Add a new static transform to the broadcaster.
RobotBroadcaster(const RobotConstPtr &robot, const std::string &base_frame="world", const std::string &name="robowflex")
Constructor. Sets up TF2 broadcaster.
ros::NodeHandle nh_
Handle for publishing.
void stop()
Stop publishing TF and joint information.
void start()
Begin publishing TF and joint information.
ros::Publisher state_pub_
State publisher.
void update()
Send out the TF and joint information.
~RobotBroadcaster()
Destructor.
void removeStaticTransform(const std::string &name)
Remove a named static transform.
A const shared pointer wrapper for robowflex::Robot.
#define RBX_ERROR(fmt,...)
Output a error logging message.
Functions for loading and animating robots in Blender.
geometry_msgs::TransformStamped transformEigenToMsg(const std::string &source, const std::string &target, const RobotPose &tf)
Encode a transform as a message.
Main namespace. Contains all library classes and functions.
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.