i have created a xacro file for a wheeled robot. a snippet of it is like this:
<robot name="em_3905" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Degree-to-radian conversions -->
<xacro:property name="degrees_45" value="0.785398163"/>
<xacro:property name="degrees_90" value="1.57079633"/>
<!-- chassis_length is measured along the x axis, chassis_width
along the y axis, and chassis_height along the z axis. -->
<xacro:property name="chassis_length" value="4"/>
<xacro:property name="chassis_width" value="1"/>
<xacro:property name="chassis_height" value="0.01"/>
<xacro:property name="chassis_mass" value="2.788"/>
<xacro:property name="wheel_radius" value="0.2"/>
i have a python script which is dependent on the chassis_length and chassis_width and wheel_radius
parameters from this xacro file.
and my python_script:
#!/usr/bin/env python
import rospy
import numpy as np
from numpy import pi
from std_msgs.msg import Float64
from geometry_msgs.msg import Twist
class steering:
def __init__(self):
rospy.init_node("steering_controller", anonymous=True)
rospy.Subscriber("/cmd_vel", Twist, self.cmd_vel_callback)
self.steering_L_pub = rospy.Publisher("/xacro/left_steering_wheel_position_controller/command", Float64, queue_size=10)
self.steering_R_pub = rospy.Publisher("/xacro/right_steering_wheel_position_controller/command", Float64, queue_size=10)
self.str_L = Float64()
self.str_R = Float64()
self.drive_L = Float64()
self.drive_R = Float64()
self.Vx = 0.0
self.Wz = 0.0
self.max_alp = pi/2.0
## Car paramters
self.wheel_radius = 0.2 # meter
self.chassis_length = 4
self.chassis_width = 1
self.run()
rospy.spin()
instead of changing these parameters on both the files manually, i want to automate this by somehow linking these files in ROS. I know i can use a simple file open and extract operation in python but is there a better way to do it in ROS like with the use of set_params? if yes, how do you get params from xacro file.