Skip to content

CRISS-Robotics/learn-ros

Repository files navigation

learn-ros

Simple example to learn ROS basics

Instructions:

  1. Download dependencies
sudo apt-get install ros-noetic-ros-control ros-noetic-ros-controllers ros-noetic-gazebo-ros-control
  1. Make and move into catkin workspace
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
  1. Create a package for mobile manipulator
catkin_create_pkg mobile_manipulator_body std_msgs roscpp rospy
cd ~/catkin_ws/
catkin_make --only-pkg-with-deps mobile_manipulator_body
source devel/setup.bash
  1. Create folders for project
roscd mobile_manipulator_body
mkdir config launch urdf
  1. Download meshes
git clone -b meshes https://github.com/CRISS-Robotics/learn-ros.git
mv learn-ros/ meshes/
  1. Create URDF
cd urdf
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/robot_base.urdf
  1. Check robot in RVIZ
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roscd mobile_manipulator_body/urdf/
roslaunch urdf_tutorial display.launch model:=robot_base.urdf
  1. Control your robot
roscd mobile_manipulator_body/config/
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/control.yaml
  1. Launch in gazebo
roscd mobile_manipulator_body/launch/
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/base_gazebo_control.launch
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roslaunch mobile_manipulator_body base_gazebo_control.launch
  1. Move robot
sudo apt install ros-noetic-rqt-robot-steering
rosrun rqt_robot_steering rqt_robot_steering
rostopic list
/robot_base_velocity_controller/cmd_vel
rostopic echo /robot_base_velocity_controller/cmd_vel
  1. Add LIDAR
roscd mobile_manipulator_body/urdf/

Add LIDAR Code in mobile_manipulator.urdf

<link name="laser_link">
  <collision>
   <origin xyz="0 0 0" rpy="0 0 0"/>
   <geometry>
    <box size="0.1 0.1 0.1"/>
   </geometry>
  </collision>
  <visual>
   <origin xyz="0 0 0" rpy="0 0 0"/>
    <geometry>
     <box size="0.05 0.05 0.05"/>
    </geometry>
  </visual>
  <inertial>
    <mass value="1e-5" />
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
  </inertial>
</link>

<joint name="laser_joint" type="fixed">
  <axis xyz="0 1 0" />
  <origin xyz="0.350 0 0.115" rpy="0 0 0"/>
  <parent link="base_link"/>
  <child link="laser_link"/>
</joint>

<gazebo reference="laser_link">
  <sensor type="ray" name="laser">
    <pose>0 0 0 0 0 0</pose>
    <visualize>true</visualize>
    <update_rate>40</update_rate>
    <ray>
    <scan>
    <horizontal>
      <samples>720</samples>
      <resolution>1</resolution>
      <min_angle>-3.14159</min_angle>
      <max_angle>3.14159</max_angle>
    </horizontal>
    </scan>
    <range>
    <min>0.10</min>
    <max>30.0</max>
    <resolution>0.01</resolution>
    </range>
    </ray>
    <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_laser.so">
      <topicName>/scan</topicName>
      <frameName>laser_link</frameName>
    </plugin>
  </sensor>
</gazebo>

Check it out in gazebo

cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roslaunch mobile_manipulator_body base_gazebo_control.launch
  1. Make robot arm urdf
roscd mobile_manipulator_body/urdf/
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/robot_arm.urdf
  1. Test the arm
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roscd mobile_manipulator_body/urdf/
roslaunch urdf_tutorial display.launch model:=robot_arm.urdf
Change the Fixed Frame to world
  1. Add control for arm
roscd mobile_manipulator_body/config/
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/arm_control.yaml
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/joint_state_controller.yaml
  1. Add arm launch code
roscd mobile_manipulator_body/launch/
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/arm_gazebo_control.launch
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roslaunch mobile_manipulator_body arm_gazebo_control.launch
  1. Test arm
rostopic pub /arm_controller/command trajectory_msgs/JointTrajectory '{joint_names: ["arm_base_joint","shoulder_joint", "bottom_wrist_joint", "elbow_joint","top_wrist_joint"], points: [{positions: [-0.1, 0.5, 0.02, 0, 0], time_from_start: [1,0]}]}' -1
rostopic pub /arm_controller/command trajectory_msgs/JointTrajectory '{joint_names: ["arm_base_joint","shoulder_joint", "bottom_wrist_joint", "elbow_joint","top_wrist_joint"], points: [{positions: [0, 0, 0, 0, 0], time_from_start: [1,0]}]}' -1
  1. Combine Arm and Body
roscd mobile_manipulator_body/urdf/
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/mobile_manipulator.urdf
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roscd mobile_manipulator_body/urdf/
roslaunch urdf_tutorial display.launch model:=mobile_manipulator.urdf
  1. Control the robot
roscd mobile_manipulator_body/launch/
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/mobile_manipulator_gazebo.launch
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roslaunch mobile_manipulator_body mobile_manipulator_gazebo.launch
  1. Place this in a world
roscd mobile_manipulator_body/
mkdir worlds && cd worlds
wget https://raw.githubusercontent.com/CRISS-Robotics/learn-ros/main/postoffice.world
  1. Add this code to launch file
  <!-- Gazebo post office environment -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="/home/(test)/catkin_ws/src/mobile_manipulator_body/worlds/postoffice.world"/>
  </include>
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
  1. Make everything work
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
roslaunch mobile_manipulator_body mobile_manipulator_gazebo.launch
rosrun rqt_robot_steering rqt_robot_steering
/robot_base_velocity_controller/cmd_vel
rostopic pub /arm_controller/command trajectory_msgs/JointTrajectory '{joint_names: ["arm_base_joint","shoulder_joint", "bottom_wrist_joint", "elbow_joint","top_wrist_joint"], points: [{positions: [-0.1, 0.5, 0.02, 0, 0], time_from_start: [1,0]}]}' -1
rostopic pub /arm_controller/command trajectory_msgs/JointTrajectory '{joint_names: ["arm_base_joint","shoulder_joint", "bottom_wrist_joint", "elbow_joint","top_wrist_joint"], points: [{positions: [0, 0, 0, 0, 0], time_from_start: [1,0]}]}' -1
sudo apt install ros-noetic-tf2-tools
rosrun tf2_tools view_frames.py

About

Simple example to learn ROS basics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published