-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ros1 motor enable srv #113
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5f08a01
add motors enable srv
KmakD 982f724
add reseting can callback times
KmakD b456af2
disable motors if script reset fails
KmakD ec8799d
working solution
KmakD 94d26bc
fix
KmakD d117f85
IO initial state pth1.05
KmakD 12d4457
remove unneccessary method
KmakD 8734770
fix type
KmakD eda61d3
update README
KmakD 9e83621
Update panther_power_control/README.md
KmakD c98b388
review changes
KmakD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,7 +13,7 @@ | |||||
from std_msgs.msg import Bool | ||||||
from std_srvs.srv import Trigger, TriggerRequest, TriggerResponse | ||||||
|
||||||
from panther_msgs.msg import DriverState, FaultFlag, ScriptFlag, RuntimeError | ||||||
from panther_msgs.msg import DriverState, FaultFlag, ScriptFlag, RuntimeError, IOState | ||||||
|
||||||
from panther_can import PantherCANSDO, PantherCANPDO | ||||||
from panther_kinematics import PantherDifferential, PantherMecanum | ||||||
|
@@ -96,6 +96,7 @@ def __init__(self, name: str) -> None: | |||||
self._driver_state_timer_period = 1.0 / 10.0 # freq. 10 Hz | ||||||
self._safety_timer_period = 1.0 / 20.0 # freq. 20 Hz | ||||||
self._time_last = rospy.Time.now() | ||||||
self._motor_off_last_time = rospy.Time.now() | ||||||
self._cmd_vel_command_last_time = rospy.Time.now() | ||||||
self._cmd_vel_timeout = 0.2 | ||||||
|
||||||
|
@@ -107,6 +108,7 @@ def __init__(self, name: str) -> None: | |||||
self._motors_effort = [0.0, 0.0, 0.0, 0.0] | ||||||
|
||||||
self._e_stop_cliented = False | ||||||
self._motor_on = False | ||||||
self._stop_cmd_vel_cb = True | ||||||
|
||||||
# ------------------------------- | ||||||
|
@@ -217,6 +219,9 @@ def __init__(self, name: str) -> None: | |||||
|
||||||
self._cmd_vel_sub = rospy.Subscriber('/cmd_vel', Twist, self._cmd_vel_cb, queue_size=1) | ||||||
self._e_stop_sub = rospy.Subscriber('hardware/e_stop', Bool, self._e_stop_cb, queue_size=1) | ||||||
self._io_state_sub = rospy.Subscriber( | ||||||
'hardware/io_state', IOState, self._io_state_cb, queue_size=1 | ||||||
) | ||||||
|
||||||
# ------------------------------- | ||||||
# Service clients | ||||||
|
@@ -351,11 +356,19 @@ def _safety_timer_cb(self, *args) -> None: | |||||
self._trigger_panther_e_stop() | ||||||
self._stop_cmd_vel_cb = True | ||||||
|
||||||
rospy.logerr_throttle( | ||||||
10.0, | ||||||
f'[{rospy.get_name()}] Unable to communicate with motor controllers (CAN interface connection failure). ' | ||||||
f'Please ensure that controllers are powered on.', | ||||||
) | ||||||
if not self._motor_on: | ||||||
rospy.logwarn_throttle( | ||||||
60.0, f'[{rospy.get_name()}] Motor controllers are not powered on' | ||||||
) | ||||||
self._motor_off_last_time = rospy.Time.now() | ||||||
else: | ||||||
# wait for motor drivers to power on before logging an error | ||||||
if rospy.Time.now() - self._motor_off_last_time < rospy.Duration(2.0) : | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return | ||||||
rospy.logerr_throttle( | ||||||
10.0, | ||||||
f'[{rospy.get_name()}] Unable to communicate with motor controllers (CAN interface connection failure)', | ||||||
) | ||||||
elif self._e_stop_cliented: | ||||||
self._stop_cmd_vel_cb = True | ||||||
else: | ||||||
|
@@ -373,6 +386,9 @@ def _cmd_vel_cb(self, data: Twist) -> None: | |||||
|
||||||
self._cmd_vel_command_last_time = rospy.Time.now() | ||||||
|
||||||
def _io_state_cb(self, io_state: IOState) -> None: | ||||||
self._motor_on = io_state.motor_on | ||||||
|
||||||
def _reset_roboteq_script_cb(self, req: TriggerRequest) -> TriggerResponse: | ||||||
try: | ||||||
if self._panther_can.restart_roboteq_script(): | ||||||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.