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

Add offset-timestamp param #109

Open
wants to merge 1 commit into
base: ros2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions joint_state_publisher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Subscribed Topics
Parameters
----------
* `rate` (int) - The rate at which to publish updates to the `/joint_states` topic. Defaults to 10.
* `offset_timestamp`(double) - The offset to add to the timestamp of the published message, in seconds. Defaults to 0.0.
* `publish_default_positions` (bool) - Whether to publish a default position for each movable joint to the `/joint_states` topic. Defaults to True.
* `publish_default_velocities` (bool) - Whether to publish a default velocity for each movable joint to the `/joint_states` topic. Defaults to False.
* `publish_default_efforts` (bool) - Whether to publish a default effort for each movable joint to the `/joint_states` topic. Defaults to False.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ def __init__(self, description_file):
ParameterDescriptor(type=ParameterType.PARAMETER_BOOL))
self.declare_ros_parameter('delta', 0.0,
ParameterDescriptor(type=ParameterType.PARAMETER_DOUBLE))
self.declare_ros_parameter('offset_timestamp', 0.0,
ParameterDescriptor(type=ParameterType.PARAMETER_DOUBLE))
# In theory we would also declare 'dependent_joints' and 'zeros' here.
# Since rclpy doesn't support maps natively, though, we just end up
# letting 'automatically_declare_parameters_from_overrides' declare
Expand All @@ -390,6 +392,7 @@ def __init__(self, description_file):
self.pub_def_positions = self.get_param('publish_default_positions')
self.pub_def_vels = self.get_param('publish_default_velocities')
self.pub_def_efforts = self.get_param('publish_default_efforts')
self.offset_timestamp = self.get_param('offset_timestamp')

self.robot_description_update_cb = None

Expand Down Expand Up @@ -468,8 +471,7 @@ def set_robot_description_update_cb(self, user_cb):
def timer_callback(self):
# Publish Joint States
msg = sensor_msgs.msg.JointState()
msg.header.stamp = self.get_clock().now().to_msg()

msg.header.stamp = (self.get_clock().now() + rclpy.duration.Duration(seconds=self.offset_timestamp)).to_msg()
if self.delta > 0:
self.update(self.delta)

Expand Down