Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Assignment1.md #71

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions ROS/Assignment1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@

# SMB Gazebo Simulation Guide

## Setting Up the Environment

1. Source the workspace:
```bash
source devel/setup.bash
```

2. Launch the Gazebo simulation:
```bash
roslaunch smb_gazebo smb_gazebo.launch
```

3. List active ROS nodes:
```bash
rosnode list
```
Expected output:
```
/base_controller_spawner
/gazebo
/gazebo_gui
/rosout
/smb_robot_state_publisher
```

4. List active ROS topics:
```bash
rostopic list
```
Expected output:
```
/clock
/cmd_vel
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/gazebo_ros_control/pid_gains/LF_WHEEL_JOINT/parameter_descriptions
/gazebo_ros_control/pid_gains/LF_WHEEL_JOINT/parameter_updates
/gazebo_ros_control/pid_gains/LH_WHEEL_JOINT/parameter_descriptions
/gazebo_ros_control/pid_gains/LH_WHEEL_JOINT/parameter_updates
/gazebo_ros_control/pid_gains/RF_WHEEL_JOINT/parameter_descriptions
/gazebo_ros_control/pid_gains/RF_WHEEL_JOINT/parameter_updates
/gazebo_ros_control/pid_gains/RH_WHEEL_JOINT/parameter_descriptions
/gazebo_ros_control/pid_gains/RH_WHEEL_JOINT/parameter_updates
/imu0
/imu0/accel/parameter_descriptions
/imu0/accel/parameter_updates
/imu0/bias
/imu0/rate/parameter_descriptions
/imu0/rate/parameter_updates
/imu0/yaw/parameter_descriptions
/imu0/yaw/parameter_updates
/joint_states
/odom
/rosout
/rosout_agg
/smb_velocity_controller/cmd_vel
/smb_velocity_controller/odom
/smb_velocity_controller/parameter_descriptions
/smb_velocity_controller/parameter_updates
/tf
/tf_static
```

5. Echo the clock topic:
```bash
rostopic echo /clock
```
Expected output:
```
clock:
secs: 405
nsecs: 532000000
---
clock:
secs: 405
nsecs: 533000000
```

6. Get information about the clock topic:
```bash
rostopic info /clock
```
Expected output:
```
Type: rosgraph_msgs/Clock
Publishers:
* /gazebo (http://Ubuntu20:38511/)
Subscribers:
* /rosout (http://Ubuntu20:34993/)
* /smb_robot_state_publisher (http://Ubuntu20:39761/)
* /base_controller_spawner (http://Ubuntu20:36055/)
* /gazebo (http://Ubuntu20:38511/)
* /gazebo_gui (http://Ubuntu20:45813/)
```

7. Measure the frequency of the clock topic:
```bash
rostopic hz /clock
```
Expected output (subscribes to the clock):
```
average rate: 954.993
min: 0.001s max: 0.007s std dev: 0.00036s window: 680
```

8. Visualize the nodes and topics using `rqt_graph`:
```bash
rqt_graph
```

## Publishing Velocity Commands

1. Publish a velocity command:
```bash
rostopic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.5, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}" -r 3
```

2. Install and use `teleop_twist_keyboard` for controlling the robot:
```bash
sudo apt-get install ros-noetic-teleop-twist-keyboard
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
```
Note: The robot moves only if the terminal is the active window.

## Launching a Custom World

1. Create a new launch file in the `launch` directory of `smb_gazebo`:
```xml
<launch>
<include file="$(find smb_gazebo)/launch/smb_gazebo.launch">
<arg name="world_file" value="/usr/share/gazebo-11/worlds/robocup14_spl_field.world"/>
</include>
</launch>
```

2. Launch the new world:
```bash
roslaunch smb_gazebo <your_new_launch_file>.launch
```
40 changes: 40 additions & 0 deletions ROS_Assignment 2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.0.2)
project(my_package)

## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
gazebo_ros
pointcloud_to_laserscan
rviz
smb_control
smb_gazebo
# smb_description
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)

## Declare a catkin package
catkin_package()

## Specify additional locations of header files
## Your package locations should be included here
include_directories(
${catkin_INCLUDE_DIRS}
# Add any additional include directories here if needed
)

## Declare a C++ executable
add_executable(smb_highlevel_controller src/smb_highlevel_controller.cpp)

## Specify libraries to link a library or executable target against
target_link_libraries(smb_highlevel_controller
${catkin_LIBRARIES}
# Add any additional libraries here if needed (e.g., PCL libraries)
)

## Add dependencies to the executable
add_dependencies(smb_highlevel_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

1 change: 1 addition & 0 deletions ROS_Assignment 2/launch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

107 changes: 107 additions & 0 deletions ROS_Assignment 2/my_package.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<launch>

<!-- GAZEBO ARGUMENTS -->
<!-- Run Gazebo headless -->
<arg name="headless" default="false"/>
<!-- Model path -->
<arg name="model_path" default="$(find smb_gazebo)/"/>
<arg name="robot_namespace" default=""/>
<arg name="robot_model_name" default="smb"/>
<arg name="enable_ekf" default="true"/>

<!-- Name of the world -->
<arg name="world" default="empty"/>
<!-- Path to the world file -->
<arg name="world_file" default="$(find smb_gazebo)/worlds/$(arg world).world"/>
<arg name="laser_enabled" default="true"/>

<!-- Set the initial pose of the robot's main body -->
<arg name="x" default="0.0"/>
<arg name="y" default="0.0"/>
<arg name="z" default="0.4"/>
<arg name="roll" default="0.0"/>
<arg name="pitch" default="0.0"/>
<arg name="yaw" default="0.0"/>
<!-- Start paused -->
<arg name="paused" default="false"/>
<!-- Use simulation clock -->
<arg name="use_sim_time" default="true"/>
<!-- Debug mode -->
<arg name="debug" default="false"/>
<!-- Verbose mode -->
<arg name="verbose" default="true"/>

<arg name="laser_scan_min_height" default="0.0"/>
<arg name="laser_scan_max_height" default="0.1"/>

<!-- GUI ARGUMENTS -->
<!-- Enable/disable Gazebo GUI -->
<arg name="run_gui" default="true"/>

<!-- ROBOT ARGUMENTS -->
<!-- Name of the robot description parameter -->
<arg name="robot_description" default="robot_description"/>

<!-- Load Gazebo world -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<env name="GAZEBO_MODEL_PATH" value="$(arg model_path)"/>
<arg name="world_name" value="$(arg world_file)"/>
<arg name="paused" value="$(arg paused)"/>
<arg name="use_sim_time" value="$(arg use_sim_time)"/>
<arg name="gui" value="$(arg run_gui)"/>
<arg name="headless" value="$(arg headless)"/>
<arg name="debug" value="$(arg debug)"/>
<arg name="verbose" value="$(arg verbose)"/>
</include>

<!-- Spawn robot in Gazebo -->
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model"
args="-param $(arg robot_description) -urdf -model $(arg robot_model_name) -x $(arg x)
-y $(arg y) -z $(arg z) -R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"
output="screen"/>

<!-- Convert 3D velodyne scan to laser scan -->
<node name="pointcloud_to_laserscan" pkg="pointcloud_to_laserscan" type="pointcloud_to_laserscan_node" if="$(arg laser_enabled)">
<remap from="cloud_in" to="/rslidar_points"/>
<remap from="scan" to="/scan"/>
<rosparam>
target_frame: rslidar # Leave disabled to output scan in pointcloud frame
transform_tolerance: 0.01
min_height: $(arg laser_scan_min_height)
max_height: $(arg laser_scan_max_height)

angle_min: -1.5708 # -M_PI/2
angle_max: 1.5708 # M_PI/2
angle_increment: 0.0087 # M_PI/360.0
scan_time: 0.03333
range_min: 0.45
range_max: 50.0
use_inf: true
inf_epsilon: 1.0

# Concurrency level, affects number of pointclouds queued for processing and number of threads used
# 0 : Detect number of cores
# 1 : Single threaded
# 2->inf : Parallelism level
concurrency_level: 1
</rosparam>
</node>

<include file="$(find smb_control)/launch/control.launch">
<arg name="simulation" default="true"/>
<arg name="robot_namespace" default="$(arg robot_namespace)"/>
<arg name="robot_description" default="$(arg robot_description)"/>
<arg name="enable_ekf" default="$(arg enable_ekf)"/>
</include>

<!-- Load parameters from the YAML file -->
<rosparam file="$(find my_package)/params.yaml" command="load"/>

<!-- Start the smb_highlevel_controller node -->
<node name="smb_highlevel_controller" pkg="my_package" type="smb_highlevel_controller" output="screen"/>

<!-- Run RViz -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find my_package)/rviz/config.rviz" required="true"/>

</launch>
83 changes: 83 additions & 0 deletions ROS_Assignment 2/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0"?>
<package format="2">
<name>my_package</name>
<version>0.0.0</version>
<description>The my_package package</description>

<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> -->
<maintainer email="[email protected]">jack</maintainer>


<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>


<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/my_package</url> -->


<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="[email protected]">Jane Doe</author> -->


<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>gazebo_ros</build_depend>
<build_depend>pointcloud_to_laserscan</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rviz</build_depend>
<build_depend>smb_control</build_depend>
<build_depend>smb_description</build_depend>
<build_depend>smb_gazebo</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>gazebo_ros</build_export_depend>
<build_export_depend>pointcloud_to_laserscan</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rviz</build_export_depend>
<build_export_depend>smb_control</build_export_depend>
<build_export_depend>smb_description</build_export_depend>
<build_export_depend>smb_gazebo</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>gazebo_ros</exec_depend>
<exec_depend>pointcloud_to_laserscan</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rviz</exec_depend>
<exec_depend>smb_control</exec_depend>
<exec_depend>smb_description</exec_depend>
<exec_depend>smb_gazebo</exec_depend>
<exec_depend>std_msgs</exec_depend>


<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->

</export>
</package>
3 changes: 3 additions & 0 deletions ROS_Assignment 2/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scan_subscriber:
topic_name: "/scan"
queue_size: 1
Loading