Open mvrk33 opened 9 months ago
-open mobaXterm->sessions->SSH-> -Remote host=proxy8.remoteiot.com -specify username(agrobot1 or agrobot2 or agrobot3) -port( )
-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
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
Now add the ROS 2 GPG key with apt.
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
Then add the repository to your sources list.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt upgrade
-Desktop Install (Recommended): ROS, RViz, demos, tutorials.
sudo apt install ros-humble-desktop
-ROS-Base Install (Bare Bones): Communication libraries, message packages, command line tools. No GUI tools.
sudo apt install ros-humble-ros-base
-Development tools: Compilers and other tools to build ROS packages
sudo apt install ros-dev-tools
-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
-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
ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key
Recording and playing back data
mkdir bag_files
cd bag_files
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
ros2 bag info rosbag2_2024_03_23-17_11_07
nc -l -p 1234
nc localhost 1234 | bash
-Create a New C++ Source File:
nano hello.cpp
#include <iostream>
int main() {
std::cout << "Hello" << std::endl;
return 0;
}
./hello
-- you get output here
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
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_**
colcon build the new workspace
colcon build
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
STEP 1:
source/opt/ros/humble/setup.bash
sudo apt update
sudo apt upgrade
sudo apt-get install gedit
mkdir -p ~/ws_pub_sub/src
cd ~/ws_pub_sub/src
ros2 pkg create --build-type ament_python publisher_subscriber
STEP 2;
cd ~/ws_pub_sub/src/publisher_subscriber/publisher_subscriber/
gedit publisher.py
Before that install conda
conda activate
anaconda-navigator
close the terminal now
Step 3
got to the work space
ws_pub_sub/src/publisher_subscriber/
gedit package.xml
add the dependencies
STEP 1: #Create the workspace folder and empty package #Open a new terminal window. First, we need to source the base ROS2 environment. That is, we need to create an underlay:
source/opt/ros/humble/setup.bash
Its for editing and manipulating python files
sudo apt update sudo apt upgrade sudo apt-get install gedit
Create a workspace
mkdir -p ~/ws_pub_sub/src
This command will create the workspace called WS_pub__sub and inside of that folder, it will create a sub folder called SRC
The next step is to create a package for that we need to navigate to the SRC folder
cd ~/ws_pub_sub/src
To create a package to need to type :
ros2 pkg create --build-type ament_python publisher_subscriber
The package name is publisher_subscriber
STEP 2; #Create publisher_subscriber python node files #palce the python files in the publisher_subscriber
cd ~/ws_pub_sub/src/publisher_subscriber/publisher_subscriber/
In this folder we will create a pub and sub nodes #create a pub node. Name the file as publisher.py #we can create the publisher file by gedit or spyder
gedit publisher.py
as the gedit is not good foe the complex code we go for the syper or conda #i will create a file for that
open new terminal
Before that install conda
conda activate anaconda-navigator
launch the spyder #write the code of publisher and save it as publisher.py in the ws_pub_sub/src/publisher_subscriber/publisher_subscriber/ #the code willl be available in the internet as wll as in the ros2 fourms
write the subscriber code just like the above #sav it in the same location as publisher.py close the terminal now
Step 3 got to the work space
ws_pub_sub/src/publisher_subscriber/
gedit package.xml
add the dependencies rclpy
std_msgs save the file
create the entry point for the package
cd ws_pub_sub/src/publisher_subscriber/ gedit setup.py
in the entry points edit it as entry_points={ 'console_scripts':['publisher=publisher_subscriber.publisher:main', 'subscriber=publisher_subscriber.subscriber:main' ], }
gedit setup.cfg
check if its in empty if empty then someting is wrongcd ~/ws_pub_sub/ rosdep install -i --from-path src --rosdistro humble -y
it will retrun all are up to date
cd ~/ws_pub_sub/ colcon build
Step 4
cd ~/ws_pub_sub/
in the same dicrectory open new terminal bash the follwingsource ~/ws_pub_sub/install/setup.bash
run the node as
ros2 run publisher_subscriber publisher
to run the subscriber node open new terminal
cd ~/ws_pub_sub/
bash the follw0ing
source ~/ws_pub_sub/install/setup.bash
run the node asros2 run publisher_subscriber subscriber
Follow this for Easy Creation of pub_sub node
[Uploading Lab-1-ROS-Intro.pdf…]()