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

import rospy
from sensor_msgs.msg import JointState
from trajectory_msgs.msg import JointTrajectory

class MotorVizHelper:
    def __init__(self):
        rospy.init_node("motor_viz_helper", log_level=rospy.DEBUG, anonymous=False)
        self.joint_state_msg = JointState()
        self.joint_publisher = rospy.Publisher('joint_states', JointState, queue_size=1)
        rospy.Subscriber("walking_motor_goals", JointTrajectory, self.cb, queue_size=1)
        rospy.spin()

    def cb(self, msg:JointTrajectory):
        self.joint_state_msg.header = msg.header
        self.joint_state_msg.name = msg.joint_names
        self.joint_state_msg.position = msg.points[0].positions
        self.joint_publisher.publish(self.joint_state_msg)

helper = MotorVizHelper()
<commit_msg>Bringup: fixed and improved motor goals viz helper script. Now also works directly for walking and animations<commit_after>#!/usr/bin/env python3

import argparse

import rospy
from sensor_msgs.msg import JointState
from bitbots_msgs.msg import JointCommand
from humanoid_league_msgs.msg import Animation

class MotorVizHelper:
    def __init__(self):
        parser = argparse.ArgumentParser()
        parser.add_argument("--w", help="Directly get walking motor goals", action="store_true")
        parser.add_argument("--a", help="Directly get animation motor goals", action="store_true")
        args = parser.parse_args()

        rospy.init_node("motor_viz_helper", anonymous=False)
        self.joint_state_msg = JointState()
        self.joint_publisher = rospy.Publisher('joint_states', JointState, queue_size=1)
        if args.w:
            rospy.Subscriber("walking_motor_goals", JointCommand, self.joint_command_cb, queue_size=1)
        elif args.a:
            rospy.Subscriber("animation_motor_goals", JointCommand, self.animation_cb, queue_size=1)
        else:
            rospy.Subscriber("/DynamixelController/command", JointCommand, self.joint_command_cb, queue_size=1)

        rospy.spin()

    def joint_command_cb(self, msg:JointCommand):
        self.joint_state_msg.header = msg.header
        self.joint_state_msg.name = msg.joint_names
        self.joint_state_msg.position = msg.positions
        self.joint_publisher.publish(self.joint_state_msg)

    def animation_cb(self, msg:JointCommand):
        self.joint_state_msg.header = msg.header
        self.joint_state_msg.name = msg.position.joint_names
        self.joint_state_msg.position = msg.position.points[0].positions
        self.joint_publisher.publish(self.joint_state_msg)

helper = MotorVizHelper()

{'fraction_non_alphanumeric': 0.09467228823303948, 'fraction_numerical': 0.0038328861632809506, 'mean_word_length': 3.8423005565862707, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '928261', 'n_tokens_mistral': 848, 'n_tokens_neox': 807, 'n_words': 146}