4 from geometry_msgs.msg
import Twist, TwistStamped
5 from ds4_driver.msg
import Status
10 self.
_stamped = rospy.get_param(
'~stamped',
False)
13 self.
_frame_id = rospy.get_param(
'~frame_id',
'base_link')
20 for attr
in Status.__slots__:
21 if attr.startswith(
'axis_')
or attr.startswith(
'button_'):
22 self._attrs.append(attr)
24 self.
_pub = rospy.Publisher(
'cmd_vel', self.
_cls, queue_size=1)
25 rospy.Subscriber(
'status', Status, self.
cb_status, queue_size=1)
35 input_vals[attr] = getattr(msg, attr)
39 to_pub.header.stamp = rospy.Time.now()
46 vel_vec = getattr(twist, vel_type)
47 for k, expr
in self.
_inputs[vel_type].items():
48 scale = self.
_scales[vel_type].get(k, 1.0)
49 val = eval(expr, {}, input_vals)
50 setattr(vel_vec, k, scale * val)
52 self._pub.publish(to_pub)
56 rospy.init_node(
'ds4_twist')
63 if __name__ ==
'__main__':