-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic_tools_transfomer' into 'indigo'
Topic tools transfomer See merge request !178
- Loading branch information
Showing
15 changed files
with
445 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
mcr_common/mcr_topic_tools/ros/doc/brics_joints_to_joint_states.graphml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd"> | ||
<!--Created by yFiles for Java 2.11--> | ||
<key for="graphml" id="d0" yfiles.type="resources"/> | ||
<key for="port" id="d1" yfiles.type="portgraphics"/> | ||
<key for="port" id="d2" yfiles.type="portgeometry"/> | ||
<key for="port" id="d3" yfiles.type="portuserdata"/> | ||
<key attr.name="url" attr.type="string" for="node" id="d4"/> | ||
<key attr.name="description" attr.type="string" for="node" id="d5"/> | ||
<key for="node" id="d6" yfiles.type="nodegraphics"/> | ||
<key attr.name="Description" attr.type="string" for="graph" id="d7"/> | ||
<key attr.name="url" attr.type="string" for="edge" id="d8"/> | ||
<key attr.name="description" attr.type="string" for="edge" id="d9"/> | ||
<key for="edge" id="d10" yfiles.type="edgegraphics"/> | ||
<graph edgedefault="directed" id="G"> | ||
<data key="d7"/> | ||
<node id="n0"> | ||
<data key="d6"> | ||
<y:ShapeNode> | ||
<y:Geometry height="57.0" width="16.267266560000053" x="206.73273343999995" y="286.9319999999999"/> | ||
<y:Fill color="#FFFFFF" transparent="false"/> | ||
<y:BorderStyle hasColor="false" type="line" width="1.0"/> | ||
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" hasText="false" height="4.0" modelName="custom" textColor="#000000" visible="true" width="4.0" x="6.133633280000026" y="26.5"> | ||
<y:LabelModel> | ||
<y:SmartNodeLabelModel distance="4.0"/> | ||
</y:LabelModel> | ||
<y:ModelParameter> | ||
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> | ||
</y:ModelParameter> | ||
</y:NodeLabel> | ||
<y:Shape type="rectangle"/> | ||
</y:ShapeNode> | ||
</data> | ||
</node> | ||
<node id="n1"> | ||
<data key="d6"> | ||
<y:ShapeNode> | ||
<y:Geometry height="57.0" width="16.267266560000053" x="608.7423667200021" y="286.9319999999999"/> | ||
<y:Fill color="#FFFFFF" transparent="false"/> | ||
<y:BorderStyle hasColor="false" type="line" width="1.0"/> | ||
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" hasText="false" height="4.0" modelName="custom" textColor="#000000" visible="true" width="4.0" x="6.133633280000026" y="26.5"> | ||
<y:LabelModel> | ||
<y:SmartNodeLabelModel distance="4.0"/> | ||
</y:LabelModel> | ||
<y:ModelParameter> | ||
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> | ||
</y:ModelParameter> | ||
</y:NodeLabel> | ||
<y:Shape type="rectangle"/> | ||
</y:ShapeNode> | ||
</data> | ||
</node> | ||
<node id="n2"> | ||
<data key="d6"> | ||
<y:ShapeNode> | ||
<y:Geometry height="57.0" width="133.9999999999999" x="340.3560000000024" y="286.9319999999999"/> | ||
<y:Fill color="#993300" transparent="false"/> | ||
<y:BorderStyle color="#993300" type="line" width="1.0"/> | ||
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="31.9375" modelName="custom" textColor="#FFFFFF" visible="true" width="85.59765625" x="24.201171874999943" y="12.53125">Brics joints to | ||
joint states<y:LabelModel> | ||
<y:SmartNodeLabelModel distance="4.0"/> | ||
</y:LabelModel> | ||
<y:ModelParameter> | ||
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> | ||
</y:ModelParameter> | ||
</y:NodeLabel> | ||
<y:Shape type="rectangle"/> | ||
</y:ShapeNode> | ||
</data> | ||
</node> | ||
<edge id="e0" source="n0" target="n2"> | ||
<data key="d10"> | ||
<y:PolyLineEdge> | ||
<y:Path sx="8.131393280000111" sy="1.6028800000000274" tx="-52.74864000000224" ty="1.6028800000000274"/> | ||
<y:LineStyle color="#000000" type="line" width="1.0"/> | ||
<y:Arrows source="none" target="standard"/> | ||
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="45.90625" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="100.5390625" x="4.9701080322265625" y="-16.90887752769129">configuration_in | ||
(brics_actuator/ | ||
JointPositions)<y:LabelModel> | ||
<y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/> | ||
</y:LabelModel> | ||
<y:ModelParameter> | ||
<y:SmartEdgeLabelModelParameter angle="6.283185307179586" distance="6.044249064105637" distanceToCenter="true" position="right" ratio="0.0" segment="0"/> | ||
</y:ModelParameter> | ||
<y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/> | ||
</y:EdgeLabel> | ||
<y:BendStyle smoothed="false"/> | ||
</y:PolyLineEdge> | ||
</data> | ||
</edge> | ||
<edge id="e1" source="n2" target="n1"> | ||
<data key="d10"> | ||
<y:PolyLineEdge> | ||
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> | ||
<y:LineStyle color="#000000" type="line" width="1.0"/> | ||
<y:Arrows source="none" target="standard"/> | ||
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="45.90625" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="109.251953125" x="5.000012451174143" y="-16.940177621537714">configuration_out | ||
(sensor_msgs/ | ||
JointState)<y:LabelModel> | ||
<y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/> | ||
</y:LabelModel> | ||
<y:ModelParameter> | ||
<y:SmartEdgeLabelModelParameter angle="6.283185307179586" distance="6.012954214399904" distanceToCenter="true" position="right" ratio="0.0" segment="0"/> | ||
</y:ModelParameter> | ||
<y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/> | ||
</y:EdgeLabel> | ||
<y:BendStyle smoothed="false"/> | ||
</y:PolyLineEdge> | ||
</data> | ||
</edge> | ||
</graph> | ||
<data key="d0"> | ||
<y:Resources/> | ||
</data> | ||
</graphml> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
mcr_common/mcr_topic_tools/ros/launch/brics_joints_to_joint_states.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<include file="$(find mcr_topic_tools)/ros/launch/brics_joints_to_joint_states_example.launch"/> | ||
|
||
<test pkg="mcr_topic_tools" type="test_brics_joints_to_joint_states.py" | ||
test-name="test_brics_joints_to_joint_states" ns="mcr_common"> | ||
|
||
<remap from="~joint_configuration" to="/mcr_common/brics_joints_to_joint_states/configuration_in"/> | ||
<remap from="~component_output" to="/mcr_common/brics_joints_to_joint_states/configuration_out"/> | ||
</test> | ||
</launch> |
10 changes: 10 additions & 0 deletions
10
mcr_common/mcr_topic_tools/ros/launch/brics_joints_to_joint_states_example.launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<!-- Note: example launch file. Do not modify! --> | ||
<launch> | ||
<node pkg="mcr_topic_tools" type="brics_joints_to_joint_states_node" | ||
name="brics_joints_to_joint_states" output="screen" ns="mcr_common"> | ||
|
||
<!-- Node cycle rate (in hz) --> | ||
<param name="loop_rate" type="double" value="10.0"/> | ||
</node> | ||
</launch> |
6 changes: 6 additions & 0 deletions
6
mcr_common/mcr_topic_tools/ros/scripts/brics_joints_to_joint_states_node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python | ||
|
||
import mcr_topic_tools_ros.brics_joints_to_joint_states | ||
|
||
if __name__ == '__main__': | ||
mcr_topic_tools_ros.brics_joints_to_joint_states.main() |
Empty file.
68 changes: 68 additions & 0 deletions
68
mcr_common/mcr_topic_tools/ros/src/mcr_topic_tools_ros/brics_joints_to_joint_states.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This module transforms a brics_actuator.msg.JointPositions message | ||
into a sensor_msgs.msg.JointState message. | ||
""" | ||
#-*- encoding: utf-8 -*- | ||
|
||
import rospy | ||
import sensor_msgs.msg | ||
import brics_actuator.msg | ||
import mcr_topic_tools_ros.transformer_utils as topic_utils | ||
|
||
|
||
class BricsJointsToJointStates(object): | ||
""" | ||
Transforms a brics_actuator.msg.JointPositions message | ||
into a sensor_msgs.msg.JointState message. | ||
""" | ||
def __init__(self): | ||
# Params | ||
self.configuration_in = None | ||
|
||
# Node cycle rate (in hz) | ||
self.loop_rate = rospy.Rate(rospy.get_param('~loop_rate', 10.0)) | ||
|
||
# Publishers | ||
self.configuration_out = rospy.Publisher( | ||
'~configuration_out', sensor_msgs.msg.JointState, queue_size=1 | ||
) | ||
|
||
# Subscribers | ||
rospy.Subscriber( | ||
'~configuration_in', brics_actuator.msg.JointPositions, | ||
self.configuration_in_cb | ||
) | ||
|
||
def start(self): | ||
""" | ||
Starts the component-wise pose error calculator. | ||
""" | ||
rospy.loginfo("Ready to start...") | ||
|
||
while not rospy.is_shutdown(): | ||
if self.configuration_in: | ||
configuration_out = topic_utils.brics_joints_to_joint_state( | ||
self.configuration_in | ||
) | ||
self.configuration_out.publish(configuration_out) | ||
else: | ||
rospy.logdebug("Waiting for data...") | ||
|
||
self.loop_rate.sleep() | ||
|
||
def configuration_in_cb(self, msg): | ||
""" | ||
Obtains the joint configuration. | ||
""" | ||
self.configuration_in = msg | ||
|
||
|
||
def main(): | ||
rospy.init_node('brics_joints_to_joint_states', anonymous=True) | ||
brics_joints_to_joint_states = BricsJointsToJointStates() | ||
brics_joints_to_joint_states.start() |
30 changes: 30 additions & 0 deletions
30
mcr_common/mcr_topic_tools/ros/src/mcr_topic_tools_ros/transformer_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This module contains a collection of functions to transform topics, e.g. to convert | ||
a 'brics_actuator/JointPosition' message into a 'sensor_msgs/JointState'. | ||
""" | ||
#-*- encoding: utf-8 -*- | ||
|
||
import sensor_msgs.msg | ||
|
||
|
||
def brics_joints_to_joint_state(m): | ||
""" | ||
Transforms a PoseStamped message to a Pose, and if rounding is enable | ||
then the message elements are rounded. | ||
:param m: The message to be rounded. | ||
:type m: brics_actuator.msg.JointPosition | ||
:return: The transformed message. | ||
:rtype : sensor_msgs.msg.JointState | ||
""" | ||
message_out = sensor_msgs.msg.JointState() | ||
# Assumption: The time stamp of the first joint is used as the general time stamp | ||
message_out.header.stamp = m.positions[0].timeStamp | ||
message_out.name = [i.joint_uri for i in m.positions] | ||
message_out.position = [i.value for i in m.positions] | ||
|
||
return message_out |
Oops, something went wrong.