手柄控制高斯机械臂

#!/usr/bin/env python

import rospy, actionlib

from std_msgs.msg import Bool
from sensor_msgs.msg import Joy

from sensor_msgs.msg import JointState
from trajectory_msgs.msg import JointTrajectory
from trajectory_msgs.msg import JointTrajectoryPoint

from gauss_msgs.srv import GetInt
from gauss_msgs.srv import SetInt
from gauss_msgs.srv import CurrentTool
from gauss_msgs.msg import ToolAction
from gauss_msgs.msg import ToolGoal

from gauss_msgs.msg import RobotMoveAction
from gauss_msgs.msg import RobotMoveGoal

from gauss_commander.command_status import CommandStatus
from gauss_commander.robot_commander_exception import RobotCommanderException
from actionlib_msgs.msg import GoalStatus

from gauss_commander.command_type import CommandType as MoveCommandType
# AXES index table
AXE_JOY_L_H = 0
AXE_JOY_L_V = 1
AXE_LT      = 2
AXE_JOY_R_H = 3
AXE_JOY_R_V = 4
AXE_RT      = 5
AXE_ARROW_H = 6
AXE_ARROW_V = 7

# BUTTON index table
BUTTON_A      = 0
BUTTON_B      = 1
BUTTON_X      = 2
BUTTON_Y      = 3
BUTTON_LB     = 4
BUTTON_RB     = 5
BUTTON_BACK   = 6
BUTTON_START  = 7
BUTTON_SELECT = 8
BUTTON_JOY_L  = 9
BUTTON_JOY_R  = 10

POSITION_MODE = 100
JOINT_MODE    = 101

MIN_DELTA_XYZ = 0.01
MAX_DELTA_XYZ = 0.05
MIN_DELTA_RPY = 0.1
MAX_DELTA_RPY = 0.5

MAX_MULTIPLIER = 0.15
MIN_MULTIPLIER = 0.01
DEFAULT_MULTIPLIER = 0.07
STEP_MULTIPLIER = 0.01

class JointMode:

    def __init__(self):

        # Get params from rosparams
        self.timer_rate = rospy.get_param("~joystick_timer_rate_sec")
        self.validation = rospy.get_param("/gauss/robot_command_validation")
        self.joint_mode_timer = None
        
        self.synchronization_needed = True
        self.is_enabled = False

        self.joint_state_subscriber = rospy.Subscriber('/joint_states', 
                JointState, self.callback_joint_states)
        
        self.learning_mode_subscriber = rospy.Subscriber(
                '/gauss/learning_mode', Bool, self.callback_learning_mode)

        self.joint_trajectory_publisher = rospy.Publisher(
                '/gauss_follow_joint_trajectory_controller/command',
                JointTrajectory, queue_size=10)

        self.axes = [0,0,0,0,0,0,0,0]
        self.buttons = [0,0,0,0,0,0,0,0,0,0,0]
        self.joint_states = JointState()
        self.joint_cmd = [0,0,0,0,0,0]
        self.multiplier = DEFAULT_MULTIPLIER
        self.learning_mode_on = True
        
        self.joint_mode_timer = rospy.Timer(rospy.Duration(self.timer_rate), self.send_joint_trajectory)
        self.time_debounce_start_button = rospy.Time.now()

        self.joystick_tool_commander = JoystickToolCommander()
        try:
            rospy.wait_for_service('/gauss/current_tool', 1)
            self.current_tool_client = rospy.ServiceProxy('/gauss/current_tool', CurrentTool)            
        except Exception as e:
            print e
        
    def increase_speed(self):
        self.multiplier += STEP_MULTIPLIER
        if self.multiplier > MAX_MULTIPLIER:
            self.multiplier = MAX_MULTIPLIER

  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值