---
# System prepended metadata

title: ROS

---

# ROS1 Notes 
### Basics

Open a ubuntu terminal and run roscore and now start from from new terminal.

#### Ros master-
Manages communication between nodes. All nodes first register to the master node.


##### Node-
Basically, nodes are processes that perform some computation or task. The nodes themselves are really software processes but with the capability to register with the ROS Master node and communicate with other nodes in the system.

#### Topic-
Some nodes provide information for other nodes, as a camera feed would do, for example. Such a node is said to publish information that can be received by other nodes. The information in ROS is called a topic. A topic defines the types of messages that will be sent concerning that topic.

Nodes communicate over topics.

#### Subscriber-



#### Publisher-


`roscore` to start the Master and allow nodes to communicate
`rosnode list` to list the active nodes
`rostopic list` to list the topics associated with active ROS nodes
`rosrun package_name node_name` to start a package
`rosnode list`to see the active nodes
`rosnode info /name_of_node `

`ctrl+c` to terminate a node

### Workspace
```cd catkin_ws``` Directs to the catkin workspace
`source devel/setup.bash` Source your workspace

#### Building a package-
`cd catkin_ws/src`
`catkin_create_pkg trial std_msg rospy`
`cd ..`  `catkin_make`
`rospack depends trial` check dependencies of our package
Go to package

`sudo nano ~/.bashrc`


## TURTLEBOT3

### Installation

https://github.com/ROBOTIS-GIT/turtlebot3
https://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/#gazebo-simulation


`cd ~/catkin_ws/src`
`git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3`
`git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs`
` git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git`
`cd ..`
`catkin_make`

### Launching Gazebo
`export TURTLEBOT3_MODEL=waffle`


` roslaunch turtlebot3_gazebo turtlebot3_world.launch`

**Teleoperation-** 

` roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch`


**Gmapping**

`sudo apt-get install ros-noetic-slam-gmapping`

`export TURTLEBOT3_MODEL=waffle`
`roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping`

`rosrun map_server map_saver -f ~/name`

2 types of file are created - .pgm (greyscale image) , .yaml (details of the map)

Gazebo aborting error -
https://github.com/uuvsimulator/uuv_simulator/issues/432

**Path Planning using move_base**

`export TURTLEBOT3_MODEL=burger`
`roslaunch turtlebot3_gazebo turtlebot3_world.launch`


`export TURTLEBOT3_MODEL=burger`
`roslaunch turtlebot3_navigation turtlebot3_navigation.launch` 

If move_base node not running it might be problem of wsl to open launch file . Open vs_code and try to see any option.

`rostopic list`
`rosnode list`

Two topics are published regarding goal 
one from rviz to move_base /move_base_simple/goal

**`turtlebot3_navigation.launch`** Launch file - Defining the turtlebot3 urdf

1. `Map server node` - Loads the map 
2. `amcl.launch`- Monte carlo localisation, contains all configuration parameter

3. `move_base node`- Links the local and global path planner

4. Launching rviz

`rostopic echo intialpose` gives pose through rviz of pose selected by 2d pose estimate

`rostopic echo amcl_pose` gives intial pose of the robot

### Explore_lite implementation on Turtlebot

1. `export TURTLEBOT3_MODEL=waffle`


` roslaunch turtlebot3_gazebo turtlebot3_world.launch`

2. `export TURTLEBOT3_MODEL=waffle`

`roslaunch turtlebot3_navigation turtlebot3_navigation.launch` 

3. `export TURTLEBOT3_MODEL=waffle`
`roslaunch turtlebot3_slam turtlebot3_gmapping.launch`
   
4. `roslaunch explore_lite explore.launch`






