mirror of
https://github.com/SHC-ASTRA/rover-ros2.git
synced 2026-02-11 09:20:40 +00:00
feat: (arm) switch IK control from position to velocity
This commit is contained in:
@@ -8,7 +8,7 @@ import glob
|
|||||||
import time
|
import time
|
||||||
import atexit
|
import atexit
|
||||||
import signal
|
import signal
|
||||||
from std_msgs.msg import String
|
from std_msgs.msg import String, Header
|
||||||
from sensor_msgs.msg import JointState
|
from sensor_msgs.msg import JointState
|
||||||
from astra_msgs.msg import SocketFeedback, DigitFeedback, ArmManual
|
from astra_msgs.msg import SocketFeedback, DigitFeedback, ArmManual
|
||||||
from astra_msgs.msg import ArmFeedback, VicCAN
|
from astra_msgs.msg import ArmFeedback, VicCAN
|
||||||
@@ -191,18 +191,26 @@ class SerialRelay(Node):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def joint_command_callback(self, msg: JointState):
|
def joint_command_callback(self, msg: JointState):
|
||||||
# Embedded takes deg*10, ROS2 uses Radians
|
if len(msg.position) < 7 and len(msg.velocity) < 7: # one or the other needs to be filled
|
||||||
positions = [math.degrees(pos) * 10 for pos in msg.position]
|
return
|
||||||
# Axis 2 & 3 URDF direction is inverted
|
|
||||||
positions[2] = -positions[2]
|
|
||||||
positions[3] = -positions[3]
|
|
||||||
|
|
||||||
# Set target angles for each arm axis for embedded IK PID to handle
|
# Assumed order: Axis0, Axis1, Axis2, Axis3, Wrist_Yaw, Wrist_Roll, Gripper
|
||||||
command = f"can_relay_tovic,arm,32,{positions[0]},{positions[1]},{positions[2]},{positions[3]}\n"
|
# TODO: formalize joint names in URDF, refactor here to depend on joint names
|
||||||
# Wrist yaw and roll
|
# Embedded takes deg*10, ROS2 uses Radians
|
||||||
command += f"can_relay_tovic,digit,32,{positions[4]},{positions[5]}\n"
|
velocities = [math.degrees(vel) * 10 if abs(vel) > 0.05 else 0.0 for vel in msg.velocity]
|
||||||
# Gripper IK does not have adequate hardware yet
|
# Axis 2 & 3 URDF direction is inverted
|
||||||
self.send_cmd(command)
|
velocities[2] = -velocities[2]
|
||||||
|
velocities[3] = -velocities[3]
|
||||||
|
|
||||||
|
# Axis 0-3
|
||||||
|
arm_cmd = VicCAN(mcu_name="arm", command_id=43, data=velocities[0:3])
|
||||||
|
arm_cmd.header = Header(stamp=self.get_clock().now().to_msg())
|
||||||
|
# Wrist yaw and roll, gripper included for future use when have adequate hardware
|
||||||
|
digit_cmd = VicCAN(mcu_name="digit", command_id=43, data=velocities[4:6])
|
||||||
|
digit_cmd.header = Header(stamp=self.get_clock().now().to_msg())
|
||||||
|
|
||||||
|
self.anchor_tovic_pub_.publish(arm_cmd)
|
||||||
|
self.anchor_tovic_pub_.publish(digit_cmd)
|
||||||
|
|
||||||
def send_manual(self, msg: ArmManual):
|
def send_manual(self, msg: ArmManual):
|
||||||
axis0 = msg.axis0
|
axis0 = msg.axis0
|
||||||
|
|||||||
Reference in New Issue
Block a user