I would like to detect if the Panther’s power switch is set to CPU-ONLY or ALL position. Is there a rostopic or service that shows the power switch state?
I noticed that /battery messages are only published when switch position is set to ALL. I could use this to deduce the switch position. This is not desirable solution, I would prefer a more deterministic method.
Hi jkyn_pff
I am terribly sorry I completely forgot to reply to you. You can detect that on a pin 22 on your raspberry pi.
Here is example code on to do this:
import rospy
from std_msgs.msg import Bool
import RPi.GPIO as GPIO
def talker():
pub = rospy.Publisher('motor_switch_position', Bool, queue_size=10)
rospy.init_node('motor_switch_state_publisher', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
rospy.loginfo(f'Motor Switch Position: {GPIO.input(22)}')
pub.publish(GPIO.input(22))
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass
Best regards,
Krzysztof Wojciechowski.
Thank you Krzysztof, I was able to validate GPIO 22 functionality using SysFS /sys/class/goio/gpio22.
HI Krzysztof,
Before you close this, I’d like to ask another question. Is there a similar GPIO for detecting charge cable inserted?
Thanks, Jerry
Hi jkyn_pff.
It will be implemented in hardware in the future, but currently there is no way to do that.
Best regards,
Krzysztof Wojciechowski.