Skip to content
Snippets Groups Projects
Commit cba1c561 authored by Nikhil Ambardar's avatar Nikhil Ambardar
Browse files

Delete imp.tex

parent 2dd85188
No related branches found
No related tags found
No related merge requests found
\chapter{IMPLEMENTATION}\label{ch:conclusion}
\section{Going To Details}
\subsection{WORLD MODEL IMPLEMENTATION}
The task is about implementation of the designed World Model using C++ code. The program written ,described as a node is used to display the values of position and orientation of robot joints in addition to World Model program implementation which include other classes and objects. The program is connected with Rviz motion planner and to Gazebo simulator by launching a launch file which launches the Rviz \footnote{http://wiki.ros.org/rviz/UserGuide} and Gazebo \footnote{http://gazebosim.org/} and the node file \footnote{https://git-st.inf.tu-dresden.de/nikaviator/zero/-/blob/master/src/\lstinline|robot_models_node.cpp|}. The Robot can be manipulated using a motion plan in Rviz and then plan can be used to run the simulation in Gazebo Simulator.\\
The program code is designed to take values from the robot in Gazebo Simulator and display them in output.The program also builds the object structure by initializing values and assigning them values.Every class designed is connected to the node program using the header files and contain variables that are used to build object structure in the main node program.So after launching the Rviz and Gazebo using launch file ,the program is built and run and thus displays the position and orientation values of robot joints.\\
Then the Motion is planned in Rviz using the arrows that move the parts of robots arm and executed in Gazebo thus changing the over all position of robot. After this stage the program is once again built and run and this now displays the new changed values for robot joints position and orientation in Gazebo simulator. The results are then shared in evaluation section. More details about the tools and attributes they can handle are described below.
\newpage
\section{Tools Used}
The tools used for implementation stage in the task are -
\subsection{Clion IDE}
This is the editor used to write C++ code for a project in this case task and compile and run it. It provides many aides to help reduce the programmers workload and automate the process by providing many suggestions using inbuilt libraries and pointing out logic errors in advance and helps mitigates errors and warnings that may come at a later stage.It can be started by clicking on the icon but it is recommended to start this from terminal by typing "CLion".The following figure shows how CLion IDE looks like and also talks about some of its features.\\
\begin{figure}
\centering
\includegraphics[width=1.0\linewidth]{"../../Screenshot from 2020-10-14 04-08-02"}
\caption{CLion Screenshot}
\label{fig:screenshot-from-2020-10-14-04-08-02}
\end{figure}
Fig.6.1 On the left side the file structure is shown. On right side the files opened are shown under each tab. On the left the class files are visible for 11 classes under src folder and at bottom in this structure there is CMakeLists.txt file visible which is also used in this case to help set the configuration for executables. In the src folder there also exist file \lstinline|robot_models_node.cpp| visible below the .gitkeep statement. Above src folder there also exist a launch folder containing launcher.launch file in red . This contains launch commands to launch rviz , gazebo and the node file.
\newpage
\subsection{MoveIT-Rviz}
This is Motion Planner used to plan the motion of robot Franka Panda. This connects to simulator for running real world simulations using the Robot Operating System (ROS) and launch file.Above is screenshot for Rviz.\\
\begin{figure}
\centering
\includegraphics[width=1.0\linewidth]{"../../Screenshot from 2020-10-14 04-13-00"}
\caption{MoveIT / RVIZ Screenshot}
\label{fig:screenshot-from-2020-10-14-04-13-00}
\end{figure}
Fig.6.2 This is what Rviz motion planner looks like. The robot is stationary in this case and can be moved using arrows displayed in different colors to attempt motion in different directions.The 7 joint of Robot Panda give it immense flexibility but there maybe some motions which are not possible. The Displays on the top left shown are showing various different parameters which Rviz can help tune and change.Some of them are Robot Description and Planning Scene Topic and there is Plan and Execute button which can be used to run the plan once the arm is moved to a new position termed as final position. The plan can be executed in Gazebo Simulator by clicking Plan and Execute button and the trajectory is visible in the Rviz and then almost immidiately the Gazebo simulator executes the motion.\\
When starting RVIZ for first time there is an empty world and then Add button need to be clicked in Displays section .The option of Motion Planning is selected from the list.This enables us to set various field parameters and their values like some of them are Fixed Frame , Robot Description , Planning Scene Topic , Planning Group and Planning Request and more like Planning Trajectory and many more and they can be explored further using online tutorials provided by ROS MoveIT.
\newpage
\subsection{Gazebo}
This is real world simulator which simulates robot motion with real world parameters tuned to check if the motion plan is executable and feasible in real world.This also provide values to program using listener tf buffer in the node program but this is explained in detail later.Below is a figure showing Gazebo simulator.\\
\begin{figure}
\centering
\includegraphics[width=1.0\linewidth]{"../../Screenshot from 2020-10-14 04-13-12"}
\caption{Gazebo Screenshot}
\label{fig:screenshot-from-2020-10-14-04-13-12}
\end{figure}
In this task there was no need to explore functionality or fiddle any of features in Gazebo. It was used to visualize motion plan of Rviz-MoveIt and seen if this is real world feasible in Gazebo. In this tool it is possible to tune a lot of real world parameters and the ones related to Robot Panda are torques on joints
\newpage
\subsection{Gitlab}
To upload code as package to a central repository. This is a widely used repository for students in university setting.
It shows the projects available under the namespace . They can be clicked to view files structure under one particular project.
\begin{figure}
\centering
\includegraphics[width=1.0\linewidth]{"../Screenshot from 2020-10-14 20-16-28"}
\caption{Gitlab Screenshot}
\label{fig:screenshot-from-2020-10-14-20-16-28}
\end{figure}
\newpage
\section{Programming The Implementation Of World Model}
WORLD MODEL - To implement the World Model , ten files were created each for one of the classes. They were created as files to be included as header files(.h) in the main node program called in this case \lstinline{robot_models_node.cpp}.Each header file describe the implementation of one class and its functionalities by using variables which are then objectified in the main node program.\\
The main program is used to add objects to the classes and used to input the values into variables using those objects and then run the implementation to display output.\\
The following paragraphs describe the modules of the program used in implementation.\\
\lstset {language=C++}
\lstset{
basicstyle=\fontsize{11}{11}\selectfont\ttfamily
}
\begin{lstlisting}
int main(int argc, char** argv) {
ros::init(argc, argv, "ROSNODE1");
ros::NodeHandle nodehandle("namespacename");
ros::AsyncSpinner spinner(1);
spinner.start();
ROSINFO("HELLO, WORLD");
\end{lstlisting}
Here the main function is defined and the ROS node defined and initialized. Also a Node handle is specified and a spin loop is initiated to start the program .An output message is then printed which in this case is HELLO WORLD.\\
\lstset {language=C++}
\lstset{
basicstyle=\fontsize{11}{11}\selectfont\ttfamily
}
\begin{lstlisting}
abstractobject o1;
graspobject o2;
hand o3;
humanspace o4;
joint o5g;
obstacle o6;
robot o7;
robotfpe o8;
world o9;
worldobject o10;
\end{lstlisting}
This is an example of declaring objects for all the classes which are included into the main node file \lstinline{robot_models_node.cpp} ,using header files.
Here objects are defined which are later used to input values into variables defined in the classes.
\lstset {language=C++}
\lstset{
basicstyle=\fontsize{11}{11}\selectfont\ttfamily
}
\begin{lstlisting}
o9.c->robname="Robot FPE";
o9.c->of=true;
o9.c->moving=false;
\end{lstlisting}
This is an example of defining values to the variables in the classes included as header files inside the main program.In many cases pointers are used because they are useful to implement association and aggregation functionalities to program which are imperative.\\
Association is used where classes are together related by a relation which is not inheritance but only associated to each other because they use each other's values.In this case the class quaternion is associated to worldobject class by association relation which is implemented by including the associated class quaternion.h as header file.\\
Aggregation is used where a class if do not exist must not let its child classes be instantiated and used.
In this case world class is in aggregation relation to abstract object class which have child classes as Grasp Object and Obstacle class.So if the world class were not to exist the Grasp Object and Obstacle Class cannot be initialized or used.
So pointers are used to take input values for child classes using pointer variables of world class.
\lstset {language=C++}
\lstset{
basicstyle=\fontsize{11}{11}\selectfont\ttfamily
}
\begin{lstlisting}
tf2ros::Buffer tfBuffer;
tf2ros::TransformListener tfListener(tfBuffer);
\end{lstlisting}
tf2 is used to listen to values of variables and hence a buffer is allocated and used. After this a listener object is defined for tf2 which will be later used to listen the values and use them in program.
\lstset {language=C++}
\lstset{
basicstyle=\fontsize{11}{11}\selectfont\ttfamily
}
\begin{lstlisting}
while (nodehandle.ok()) {
for (const auto topic : ROSNODE1::topics)
{
geometrymsgs::TransformStamped transformStamped1;
geometrymsgs::TransformStamped transformStamped2;
geometrymsgs::TransformStamped transformStamped3;
\end{lstlisting}
while loop is started and objects named transformStamped1...n are defined here one for each joint.
\lstset {language=C++}
\lstset{
basicstyle=\fontsize{11}{11}\selectfont\ttfamily
}
\begin{lstlisting}
try {
transformStamped1=tfBuffer.lookupTransform("world",o5a.name,ros::Time(0));
transformStamped2=tfBuffer.lookupTransform("world",o5b.name,ros::Time(0));
transformStamped3=tfBuffer.lookupTransform("world",o5c.name,ros::Time(0));
...
\end{lstlisting}
A try catch block is used to compare and connect the attribute of robot for which we seek values i.e. in this case joint 1...7 ,relative to standard world and store them in the defined objects transformStamped1,2,3....\\
Then exceptions are caught and some statements defined for this .This is in case some things don't work.
\lstset {language=C++}
\lstset{
basicstyle=\fontsize{10}{11}\selectfont\ttfamily
}
\begin{lstlisting}
o5a.p1[0]=transformStamped1.transform.translation.x;
o5a.p1[1]=transformStamped1.transform.translation.y;
o5a.p1[2]=transformStamped1.transform.translation.z;
ROSINFOSTREAM("pandalink1 Position is"<<"x="<< o5a.p1[0]<<",y="<<o5a.p1[1]<<",
z="<<o5a.p1[2]);
o5a.or2.w=transformStamped1.transform.rotation.w;
o5a.or2.x=transformStamped1.transform.rotation.x;
o5a.or2.y=transformStamped1.transform.rotation.y;
o5a.or2.z=transformStamped1.transform.rotation.z;
ROSINFOSTREAM("pandalink1 Orientation is"<<"w="<< o5a.or2.w<<",x="<<o5a.or2.x<<",
y="<<o5a.or2.y<<",z="<<o5a.or2.z);
\end{lstlisting}
Here in these steps the object variables take input the objects values from listener object transformStamped and store them in the node program and which then outputs these values.All the static variable defined in the program are initialized with 0 value before using them.\\
This program thus listens to values from simulation and displays using appropriate output statements. The robot in Gazebo is thus connected to Rviz motion planner using ROS which enables the node program \lstinline|robot_models_node.cpp|, to listen to desired values in this case position and orientation of joints .
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment