forked from jsk-ros-pkg/jsk_aerial_robot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ninja][Motion][WIP] workaround to use trajectory generation rather t…
…han simple nav.
- Loading branch information
1 parent
e622f0e
commit 7f286c1
Showing
4 changed files
with
112 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<arg name = "module_ids" default=""/> | ||
<arg name = "real_machine" default="true"/> | ||
<node pkg="ninja" type="assembly_motion.py" name="" output="screen" > | ||
<param name = "module_ids" value="$(arg module_ids)"/> | ||
<param name = "real_machine" value="$(arg real_machine)"/> | ||
</node> | ||
</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
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,41 @@ | ||
#!/usr/bin/env python | ||
|
||
import rospy | ||
from geometry_msgs.msg import PoseStamped | ||
import numpy as np | ||
import tf | ||
|
||
class coordTransformer(): | ||
def __init__(self, | ||
robot_name = 'ninja1'): | ||
self.robot_name = robot_name | ||
self.listener = tf.TransformListener() | ||
|
||
def posTransform(self, curr_coord, dist_coord, target_pos_curr): | ||
try: | ||
self.listener.waitForTransform(self.robot_name+'/'+curr_coord, self.robot_name+'/'+dist_coord, rospy.Time(), rospy.Duration(5.0)) | ||
|
||
(trans, rot) = self.listener.lookupTransform(self.robot_name+'/'+curr_coord, self.robot_name+'/'+dist_coord, rospy.Time(0)) | ||
|
||
transform_matrix = tf.transformations.quaternion_matrix(rot) | ||
transform_matrix[:3, 3] = trans | ||
|
||
target_pos_curr_4d = np.array(list(target_pos_curr) + [1.0]) | ||
|
||
target_pos_dist_4d = np.dot(transform_matrix, target_pos_curr_4d) | ||
|
||
target_pos_dist = target_pos_dist_4d[:3] | ||
|
||
return target_pos_dist | ||
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException) as e: | ||
rospy.logerr("Transform error: %s", e) | ||
return None | ||
|
||
if __name__ == '__main__': | ||
try: | ||
rospy.init_node("coordTransformer") | ||
trans = coordTransformer(robot_name = 'ninja1'); | ||
target_base = [1,0,0] | ||
rospy.loginfo(trans.posTransform('fc', 'cog', target_base)) | ||
rospy.spin() | ||
except rospy.ROSInterruptException: pass |
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