<commit_before>#!/usr/bin/env python

import sys, time
import rospy
from raspimouse_ros.srv import *
from raspimouse_ros.msg import *
from std_msgs.msg import UInt16


def switch_motors(onoff):
    rospy.wait_for_service('/raspimouse/switch_motors')
    try:
        p = rospy.ServiceProxy('/raspimouse/switch_motors', SwitchMotors)
        res = p(onoff)
        return res.accepted
    except rospy.ServiceException, e:
        print "Service call failed: %s"%e
    else:
        return False

def raw_control(left_hz,right_hz):
    pub = rospy.Publisher('/raspimouse/motor_raw', MotorFreqs, queue_size=10)

    if not rospy.is_shutdown():
        d = MotorFreqs()
        d.left = left_hz
        d.right = right_hz
        pub.publish(d)

def buzzer(hz):
    pub = rospy.Publisher('/raspimouse/buzzer', UInt16, queue_size=10)
    rospy.init_node('operation_checker', anonymous=True)

    if not rospy.is_shutdown():
        pub.publish(hz)

def lightsensor_callback(data):
    print "lightsensors:", data.left_forward, data.left_side, data.right_side, data.right_forward

def switch_callback(data):
    print "switches:",data.front, data.center, data.rear

def sensors():
    subls = rospy.Subscriber('/raspimouse/lightsensors', LightSensorValues, lightsensor_callback)
    subsw = rospy.Subscriber('/raspimouse/switches', Switches, switch_callback)


def pos_control(left_hz,right_hz,time_ms):
    rospy.wait_for_service('/raspimouse/put_motor_freqs')
    try:
        p = rospy.ServiceProxy('/raspimouse/put_motor_freqs', PutMotorFreqs)
        res = p(left_hz,right_hz,time_ms)
        return res.accepted
    except rospy.ServiceException, e:
        print "Service call failed: %s"%e
    else:
        return False

if __name__ == "__main__":
    ### buzzer test ###
    print >> sys.stderr, "test of the buzzer"
    buzzer(1000)
    time.sleep(2.0)
    buzzer(0)

    ### motor_raw test ###
    print >> sys.stderr, "test of raw control of the motors"
    if not switch_motors(True):
        print "[check failed]: motors are not empowered"

    raw_control(0,0)<commit_msg>Remove the namespace string from the test node<commit_after>#!/usr/bin/env python

import sys, time
import rospy
from raspimouse_ros.srv import *
from raspimouse_ros.msg import *
from std_msgs.msg import UInt16


def switch_motors(onoff):
    rospy.wait_for_service('/switch_motors')
    try:
        p = rospy.ServiceProxy('/switch_motors', SwitchMotors)
        res = p(onoff)
        return res.accepted
    except rospy.ServiceException, e:
        print "Service call failed: %s"%e
    else:
        return False

def raw_control(left_hz,right_hz):
    pub = rospy.Publisher('/motor_raw', MotorFreqs, queue_size=10)

    if not rospy.is_shutdown():
        d = MotorFreqs()
        d.left = left_hz
        d.right = right_hz
        pub.publish(d)

def buzzer(hz):
    pub = rospy.Publisher('/buzzer', UInt16, queue_size=10)
    rospy.init_node('operation_checker', anonymous=True)

    if not rospy.is_shutdown():
        pub.publish(hz)

def lightsensor_callback(data):
    print "lightsensors:", data.left_forward, data.left_side, data.right_side, data.right_forward

def switch_callback(data):
    print "switches:",data.front, data.center, data.rear

def sensors():
    subls = rospy.Subscriber('/lightsensors', LightSensorValues, lightsensor_callback)
    subsw = rospy.Subscriber('/switches', Switches, switch_callback)


def pos_control(left_hz,right_hz,time_ms):
    rospy.wait_for_service('/put_motor_freqs')
    try:
        p = rospy.ServiceProxy('/put_motor_freqs', PutMotorFreqs)
        res = p(left_hz,right_hz,time_ms)
        return res.accepted
    except rospy.ServiceException, e:
        print "Service call failed: %s"%e
    else:
        return False

if __name__ == "__main__":
    ### buzzer test ###
    print >> sys.stderr, "test of the buzzer"
    buzzer(1000)
    time.sleep(2.0)
    buzzer(0)

    ### motor_raw test ###
    print >> sys.stderr, "test of raw control of the motors"
    if not switch_motors(True):
        print "[check failed]: motors are not empowered"

    raw_control(0,0)
{'fraction_non_alphanumeric': 0.1137855579868709, 'fraction_numerical': 0.008266472161439338, 'mean_word_length': 3.404710920770878, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1522730', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1448, 'n_words': 304}