Python Ros - Alternative way to map a sine wave to motor -


currently have motor running in ros correctly maps sine wave can see via "rqt_plot" function in terminal. code desired effect:

    pub = rospy.publisher("/tilt_controller/command", float64, latch=true)  global cmd cmd = 5.0 global count  count = 0 global count2 count2=0 def state_callback(msg):     #rospy.loginfo(msg)     #print msg.current_pos     global cmd     global count     global count2     period = 50     m = 2     count = count +1     if count==10:         count = 0         count2 = count2+1         if count2 == period:             count2 =0         cmd = m*math.sin(((2*math.pi)/period)*count2)         #cmd = cmd*(-1)         pub.publish(cmd)      #rospy.sleep(2.0)    def led_control_demo():      rospy.init_node('led_control_demo')      #rospy.subscriber("/motor_states/pan_tilt_port", motorstatelist, motor_callback)      rospy.subscriber("/tilt_controller/state", jointstate, state_callback)      rospy.spin()  if __name__ == '__main__':      #rospy.init.node("led_control_demo")      led_control_demo() 

although code maps sine wave accurately looking @ alternative ways possibly improve accuracy have hit wall. can suggest or think of alternative method more accurately map dynamixel motor sine wave. hope clear enough , thank you.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -