speed.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 import rospy
3 from std_msgs.msg import Bool
4 from dataspeed_ulc_msgs.msg import UlcCmd
5 
6 
7 # This is a base class that is inherited by SpeedSquareWave and SpeedSineWave
8 class Speed(object):
9 
10  def __init__(self):
11  rospy.Timer(rospy.Duration(0.02), self.timer_callback)
12 
13  self.t = 0
14  self.enabled = False
15 
16  self.ulc_cmd = UlcCmd()
17  self.ulc_cmd.enable_pedals = True
18  self.ulc_cmd.enable_steering = False
19  self.ulc_cmd.shift_from_park = False
20 
21  # Topics
22  rospy.Subscriber('/vehicle/dbw_enabled', Bool, self.recv_enable)
23  self.pub_ulc_cmd = rospy.Publisher('/vehicle/ulc_cmd', UlcCmd, queue_size=1)
24 
25  # Parameters
26  self.v1 = rospy.get_param('~v1', default=0.0) # Speed 1
27  self.v2 = rospy.get_param('~v2', default=5.0) # Speed 2
28  self.period = rospy.get_param('~period', default=10.0) # Period of wave pattern
29  self.ulc_cmd.enable_shifting = rospy.get_param('~enable_shifting', default=False) # Enable shifting between non-Park gears
30  self.ulc_cmd.linear_accel = rospy.get_param('~accel_limit', default=0.0) # Override default acceleration limit
31  self.ulc_cmd.linear_decel = rospy.get_param('~decel_limit', default=0.0) # Override default acceleration limit
32 
33  def timer_callback(self, event):
34  # Implemented in derived classes
35  pass
36 
37  def recv_enable(self, msg):
38  if msg.data and not self.enabled:
39  self.t = 0
40 
41  self.enabled = msg.data
def recv_enable(self, msg)
Definition: speed.py:37
def timer_callback(self, event)
Definition: speed.py:33


dataspeed_ulc_can
Author(s): Micho Radovnikovich
autogenerated on Thu Jul 9 2020 03:45:43