Skip to content

Instantly share code, notes, and snippets.

@callen5914
Created March 23, 2020 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save callen5914/d62e2480be8403a3d9b2c023fc72eb31 to your computer and use it in GitHub Desktop.
Save callen5914/d62e2480be8403a3d9b2c023fc72eb31 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="ursa_bot">
<!-- Degree-to-radian conversions -->
<xacro:property name="degrees_45" value="0.785398163"/>
<xacro:property name="degrees_90" value="1.57079633"/>
<xacro:property name="degrees_180" value="3.14159265"/>
<!-- Inertia Generator -->
<xacro:macro name="default_inertial" params="mass">
<inertial>
<mass value="${mass}" />
<inertia ixx="1.5" ixy="0.0" ixz="0.0" iyy="1.5" iyz="0.0" izz="1.5" />
</inertial>
</xacro:macro>
<!-- Basic Geometry of Body -->
<xacro:property name="body_length" value="1.91" />
<xacro:property name="body_width" value="0.680618" />
<xacro:property name="body_height" value="1.065022" />
<xacro:property name="body_mass" value="20.3"/>
<!-- Front Wheel Properties -->
<xacro:property name="front_wheel_width" value=".254" />
<xacro:property name="front_wheel_diameter" value="0.605" />
<xacro:property name="front_wheel_mass" value="20"/>
<!-- Steering Link Properties -->
<xacro:property name="steering_width" value="${front_wheel_width/4}" />
<xacro:property name="steering_diameter" value="${front_wheel_diameter/5}" />
<xacro:property name="steering_mass" value="2"/>
<!-- Rear Wheel Properties -->
<xacro:property name="rear_wheel_width" value="${front_wheel_width+steering_width}" />
<xacro:property name="rear_wheel_diameter" value="0.635" />
<xacro:property name="rear_wheel_mass" value="22.8"/>
<!-- Base Link -->
<link name="base_link">
<visual>
<geometry>
<box size="${body_length} ${body_width} ${body_height}"/>
</geometry>
<material name="blue" />
</visual>
<collision>
<geometry>
<box size="${body_length} ${body_width} ${body_height}"/>
</geometry>
</collision>
<xacro:default_inertial mass="${body_mass}"/>
</link>
<!-- Steering Macro -->
<xacro:macro name="steering_link" params="prefix reflect">
<link name="${prefix}_steering_link">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${steering_diameter}" length="${steering_width}"/>
</geometry>
</visual>
<collision>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${steering_diameter}" length="${steering_width}"/>
</geometry>
</collision>
<xacro:default_inertial mass="${steering_mass}"/>
</link>
<joint name="${prefix}_steering_joint" type="revolute">
<parent link="base_link"/>
<child link="${prefix}_steering_link"/>
<axis xyz="0.0 0.0 0.1"/>
<origin xyz="${(body_length / 2)- 0.1} ${(body_width / 2 + steering_width / 2) * reflect} ${-(body_height/2) + 0.1}" rpy="0.0 0.0 0.0"/>
<limit lower="-0.30" upper="0.30" effort="100.00" velocity="100.00"/>
</joint>
<!-- The Transmission -->
<transmission name="${prefix}_steering_link_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${prefix}_steering_joint">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="${prefix}_steering_link_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</xacro:macro>
<!-- Front Wheel Macro -->
<xacro:macro name="front_wheel_link" params="prefix reflect">
<link name="${prefix}_front_wheel">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${front_wheel_diameter/2}" length="${front_wheel_width}"/>
</geometry>
</visual>
<collision>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${front_wheel_diameter/2}" length="${front_wheel_width}"/>
</geometry>
</collision>
<xacro:default_inertial mass="${front_wheel_mass}"/>
</link>
<joint name="${prefix}_front_axle" type="continuous">
<parent link="${prefix}_steering_link"/>
<child link="${prefix}_front_wheel"/>
<axis xyz="0.0 0.1 0.0"/>
<origin xyz="0 ${(front_wheel_width/2 + steering_width/2) * reflect} 0"/>
</joint>
<!-- The Transmission -->
<transmission name="${prefix}_front_wheel_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${prefix}_front_axle">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="${prefix}_front_wheel_motor">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</xacro:macro>
<!-- Rear Wheel Macro -->
<xacro:macro name="rear_wheel_link" params="prefix reflect">
<link name="${prefix}_rear_wheel">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${rear_wheel_diameter/2}" length="${rear_wheel_width}"/>
</geometry>
</visual>
<collision>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${rear_wheel_diameter/2}" length="${rear_wheel_width}"/>
</geometry>
</collision>
<xacro:default_inertial mass="${rear_wheel_mass}"/>
</link>
<joint name="${prefix}_rear_axle" type="continuous">
<parent link="base_link"/>
<child link="${prefix}_rear_wheel"/>
<axis xyz="0.0 0.1 0.0"/>
<origin xyz="${-(body_length/2) + 0.1} ${(rear_wheel_width/2 + body_width/2) * reflect} ${-(body_height/2) + 0.1}"/>
</joint>
<!-- The Transmission -->
<transmission name="${prefix}_rear_wheel_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${prefix}_rear_axle">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="${prefix}_rear_wheel_motor">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</xacro:macro>
<xacro:steering_link prefix="left" reflect="1" />
<xacro:steering_link prefix="right" reflect="-1" />
<xacro:front_wheel_link prefix="left" reflect="1" />
<xacro:front_wheel_link prefix="right" reflect="-1" />
<xacro:rear_wheel_link prefix="left" reflect="1" />
<xacro:rear_wheel_link prefix="right" reflect="-1" />
<link name="front_steer">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
<geometry>
<cylinder radius="${front_wheel_diameter/2}" length="${front_wheel_width/2}"/>
</geometry>
</visual>
<collision>
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
<geometry>
<cylinder radius="${front_wheel_diameter/2}" length="${front_wheel_width/2}"/>
</geometry>
</collision>
<xacro:default_inertial mass="${front_wheel_mass}"/>
</link>
<link name="rear_wheel">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${front_wheel_diameter/2}" length="${front_wheel_width/2}"/>
</geometry>
</visual>
<collision>
<origin xyz="0.0 0.0 0.0" rpy="${degrees_90} 0.0 0.0"/>
<geometry>
<cylinder radius="${front_wheel_diameter/2}" length="${front_wheel_width/2}"/>
</geometry>
</collision>
<xacro:default_inertial mass="${front_wheel_mass}"/>
</link>
<joint name="front_steer_joint" type="revolute">
<parent link="base_link"/>
<child link="front_steer"/>
<axis xyz="0.0 0.0 0.1"/>
<origin xyz="0.7 0.0 0.0" rpy="0.0 0.0 0.0"/>
<limit lower="-0.50" upper="0.50" effort="1000" velocity="3"/>
</joint>
<joint name="rear_wheel_joint" type="continuous">
<parent link="base_link"/>
<child link="rear_wheel"/>
<axis xyz="0.0 1.0 0.0"/>
<origin xyz="-0.70 0.0 0.0" rpy="0.0 0.0 0.0"/>
<limit effort="1000.0" velocity="3.0"/>
</joint>
<transmission name="front_steer_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="front_steer_joint">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="front_steer_joint_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="rear_wheel_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="rear_wheel_joint">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="rear_wheel_joint_motor">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<!-- Gazebo plugin for ROS Control -->
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/ursa_bot</robotNamespace>
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
<legacyModeNS>false</legacyModeNS>
</plugin>
</gazebo>
</robot>
<?xml version="1.0"?>
<launch>
<arg name="namespace" default="/ursa_bot" />
<arg name="world_name" default="worlds/empty_world" />
<arg name="cmd_timeout" default="0.5"/>
<arg name="x" default="0.0"/>
<arg name="y" default="0.0"/>
<arg name="z" default="1.0" />
<arg name="roll" default="0.0"/>
<arg name="pitch" default="0.0"/>
<arg name="yaw" default="0.0"/>
<group ns="$(arg namespace)">
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" default="$(arg world_name)"/>
</include>
<rosparam file="$(find ursa_bot_ctrl)/config/joint_states.yaml" command="load" ns="/ursa_bot" />
<rosparam file="$(find ursa_bot_ctrl)/config/mobile_base.yaml" command="load" ns="/ursa_bot" />
<rosparam file="$(find ursa_bot_ctrl)/config/ursa_bot_gazebo.yaml" command="load" ns="/ursa_bot" />
<rosparam file="$(find ursa_bot_ctrl)/config/pids.yaml" command="load" ns="/ursa_bot" />
<!-- Loading the Ursa Bot into Gazebo -->
<param name="robot_description" command="$(find xacro)/xacro $(find ursa_bot_description)/urdf/ursa_bot_basic.urdf.xacro"/>
<node name="spawn_vehicle" pkg="gazebo_ros" type="spawn_model" args="-urdf -param robot_description -model ursa_bot
-gazebo_namespace /$(arg namespace)/gazebo
-x $(arg x) -y $(arg y) -z $(arg z)
-R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"/>
<!-- Standard Publisher Bullshit here -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
<param name="publish_frequency" value="30.0"/>
</node>
<node pkg="controller_manager" type="spawner" name="controller_spawner" ns="/ursa_bot" args="joint_state_controller ackermann_steering_bot_controller ackermann_steering_bot_hw_sim" output="screen" respawn="false" />
</group>
</launch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment