mvrk33 / AgroBot

5 stars 1 forks source link

ROS Intro #21

Open mvrk33 opened 4 months ago

mvrk33 commented 4 months ago

[Uploading Lab-1-ROS-Intro.pdf…]()

krishnavamsi333 commented 3 months ago

ROS 2 humble

REQUIREMENTS

steps for uploading ubuntu in pi4

mobaXterm

-open mobaXterm->sessions->SSH-> -Remote host=proxy8.remoteiot.com -specify username(agrobot1 or agrobot2 or agrobot3) -port( )

Install service

-Java JVM -Java and the JVM (Java's virtual machine) are required for the RemoteIoT service. -If your system doesn't have JVM or you find any ssl exception, please install the recommended OpenJDK 8 which is open-source and the default Java version of the ubuntu and centos Linux system. -In ubuntu please use the command as below:

sudo apt-get -y remove java*
sudo apt-get -y install openjdk-8-jre-headless

-setup

ROS2 humble

locale  # check for UTF-8
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale  # verify settings

-Setup resources

sudo apt install software-properties-common
sudo add-apt-repository universe

-Environment setup -Set up your environment by sourcing the following file.

# Replace ".bash" with your shell if you're not using bash
# Possible values are: setup.bash, setup.sh, setup.zsh
source /opt/ros/humble/setup.bash

-If you installed ros-humble-desktop above you can try some examples.

-In one terminal, source the setup file and then run a C++ talker:

source /opt/ros/humble/setup.bash
ros2 run demo_nodes_cpp talker

-In another terminal source the setup file and then run a Python listener:

source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py listener

Mandatory code

-You will need to run this command on every new shell you open to have access to the ROS 2 commands

source /opt/ros/humble/setup.bash

starting up turtlesim.

ros2 run turtlesim turtlesim_node

Open another terminal and run:

ros2 run turtlesim turtle_teleop_key

Recording and playing back data

create the new bag files

mkdir bag_files
cd bag_files

Choose a topic

ros2 bag can only record data from published messages in topics. To see the list of your system’s topics, open a new terminal and run the command:

ros2 topic list

this will return

/parameter_events
/rosout
/turtle1/cmd_vel
/turtle1/color_sensor
/turtle1/pose

In the topics tutorial, you learned that the /turtle_teleop node publishes commands on the /turtle1/cmd_vel topic to make the turtle move in turtlesim.

To see the data that /turtle1/cmd_vel is publishing, run the command:

ros2 topic echo /turtle1/cmd_vel

To record the data published to a topic use the command syntax: ros2 bag record

ros2 bag record /turtle1/cmd_vel

You can also record multiple topics, as well as change the name of the file ros2 bag saves to.Run the following command:

ros2 bag record -o subset /turtle1/cmd_vel /turtle1/pose

command used to know the storage of bag file

image

ros2 bag info rosbag2_2024_03_23-17_11_07

image

If you're referring to setting up a master-slave communication model between two terminals

In Terminal 1 (Master):

nc -l -p 1234

In Terminal 2 (Slave):

nc localhost 1234 | bash

example

-Create a New C++ Source File: nano hello.cpp

#include <iostream>

int main() {
    std::cout << "Hello" << std::endl;
    return 0;
}

In terminal 1(master)

./hello image

In terminal 2(slave)

-- you get output here image

vishaldirectr commented 2 months ago

ROS2 HUMBLE FULL BASH SCRIPT

Instructions:

1.Install git on your system: sudo apt-get install git 2.Clone this repository to your home folder! git clone https://github.com/adamjvr/ros2-bash.git cd ros2-bash/ ls cd src 3.Make script executable by navigating to the source folder of the repository directory and using the following command: chmod +x install_ros2.sh 4.Run the script: ./install_ros2.sh

vishaldirectr commented 2 months ago

ROS2 HUMBLE FULL BASH SCRIPT

Instructions:

Install git on your system: sudo apt-get install git Clone this repository to your home folder! git clone https://github.com/adamjvr/ros2-bash.git cd ros2-bash/ ls cd src Make script executable by navigating to the source folder of the repository directory and using the following command: chmod +x install_ros2.sh Run the script: ./install_ros2.sh

_ FOLLOW THIS FOR EASY INSTALLATION_**

1026Jaswanth commented 1 month ago

Creating a new python custom script

Creating Workspace (click to expand) ``` mkdir -p bumperbot_ws/src cd bumperbot_ws/ ```

colcon build the new workspace

colcon build
Creating Python & C packages (click to expand) ``` cd src ros2 pkg create --build-type ament_python bumperbot_py_examples ros2 pkg create --build-type ament_cmake bumperbot_cpp_examples ```

again build the package

colcon build

in a new terminal check the setup.bash file to run agrobot1@Trex:~/bumperbot_ws$

cd install

and run the setup.bash

. setup.bash

and check the updated packages list of ros2

ros2 pkg list

find the newly formed packages in the pkg list. Create your custom python file in the agrobot1@Trex:~/bumperbot_ws/src/bumperbot_py_examples/bumperbot_py_examples$ here i created simple_publisher.py and simple _subscriber.py after this edit the setup.py and package.xml update the setupt.py script in the console scripts , add the method of the codes here i utilised subscriber & publisher

    entry_points={
        'console_scripts': [
            'simple_publisher = bumperbot_py_examples.simple_publisher:main'
            'simple_subscriber = bumperbot_py_examples.simple_subscriber:main'
        ],

update the package.xml with the packages rclpy and stdmsgs

  <license>TODO: License declaration</license>

  <exec_depend>rclpy</exec_depend>
  <exec_depend>std_msgs</exec_depend>

  <test_depend>ament_copyright</test_depend>

build the worksapce again in new terminal and then initialize the setup.bash

. install/setup.bash

then

ros2 run bumperbot_py_examples

ros2 run bumperbot_py_examples simple_publisher

in another tab

ros2 run bumperbot_py_examples simple_subscriber