-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix canadarm's harcoded paths / update control interface / use xacro …
…file (#23) * Fix paths * Fix controller type * Set parameters for xyz/rpy for arm in launch file * Added joint traj controller and node for demo
- Loading branch information
Showing
7 changed files
with
136 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
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
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,76 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import rclpy | ||
from rclpy.node import Node | ||
from builtin_interfaces.msg import Duration | ||
|
||
from std_msgs.msg import String, Float64 | ||
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint | ||
from std_srvs.srv import Empty | ||
|
||
class MoveArm(Node): | ||
|
||
def __init__(self): | ||
super().__init__('arm_node') | ||
self.arm_publisher_ = self.create_publisher(JointTrajectory, '/canadarm_joint_trajectory_controller/joint_trajectory', 10) | ||
self.open_srv = self.create_service(Empty, 'open_arm', self.open_arm_callback) | ||
self.close_srv = self.create_service(Empty, 'close_arm', self.close_arm_callback) | ||
self.random_srv = self.create_service(Empty, 'random_arm', self.random_arm_callback) | ||
|
||
|
||
def open_arm_callback(self, request, response): | ||
traj = JointTrajectory() | ||
traj.joint_names = ["Base_Joint", "Shoulder_Roll", "Shoulder_Yaw", "Elbow_Pitch", "Wrist_Pitch", "Wrist_Yaw", "Wrist_Roll"] | ||
|
||
point1 = JointTrajectoryPoint() | ||
point1.positions = [0.0, 0.0, 0.0, -3.1416, 0.0, 0.0, 0.0] | ||
point1.time_from_start = Duration(sec=4) | ||
|
||
traj.points.append(point1) | ||
self.arm_publisher_.publish(traj) | ||
|
||
|
||
return response | ||
|
||
def close_arm_callback(self, request, response): | ||
traj = JointTrajectory() | ||
traj.joint_names = ["Base_Joint", "Shoulder_Roll", "Shoulder_Yaw", "Elbow_Pitch", "Wrist_Pitch", "Wrist_Yaw", "Wrist_Roll"] | ||
|
||
point1 = JointTrajectoryPoint() | ||
point1.positions = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] | ||
point1.time_from_start = Duration(sec=4) | ||
|
||
traj.points.append(point1) | ||
self.arm_publisher_.publish(traj) | ||
|
||
return response | ||
|
||
def random_arm_callback(self, request, response): | ||
traj = JointTrajectory() | ||
traj.joint_names = ["Base_Joint", "Shoulder_Roll", "Shoulder_Yaw", "Elbow_Pitch", "Wrist_Pitch", "Wrist_Yaw", "Wrist_Roll"] | ||
|
||
point1 = JointTrajectoryPoint() | ||
point1.positions = [1.0, -1.5, 2.0, -3.2, 0.8, 0.5, -1.0] | ||
point1.time_from_start = Duration(sec=4) | ||
|
||
traj.points.append(point1) | ||
self.arm_publisher_.publish(traj) | ||
|
||
return response | ||
|
||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
|
||
arm_node = MoveArm() | ||
|
||
rclpy.spin(arm_node) | ||
# Destroy the node explicitly | ||
# (optional - otherwise it will be done automatically | ||
# when the garbage collector destroys the node object) | ||
arm_node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Empty file.
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