Use Niryo robot through simulation¶
The simulation allows to control a virtual Ned directly from your computer.
In this tutorial, you will learn how to setup simulation on a computer.
You can use Niryo Studio with the simulation. To do so, you just have to connect Niryo Studio to “Localhost”.
Simulation environment installation¶
The whole ROS Stack is developed and tested on ROS Melodic which requires Ubuntu 18.04 to run correctly. The using of another ROS version or OS may lead to malfunctions of some packages.
To allow the simulation to run on your computer, you will need to install ROS and some packages.
All terminal command listed are for Ubuntu users.
Place yourself in the folder of your choice and create a folder catkin_ws_niryo_ned as well as a sub-folder src:
mkdir -p catkin_ws_niryo_ned/src
Then go to the folder catkin_ws_niryo_ned and clone Ned repository in the folder src. For the future operation, be sure to stay in the catkin_ws_niryo_ned folder:
cd catkin_ws_niryo_ned git clone https://github.com/NiryoRobotics/ned_ros src
You firstly need to install ROS Melodic. To do so, follow the ROS official tutorial here and chose the Desktop-Full Install.
Install additional packages¶
To ensure the functioning of all Ned’s packages, you need to install several more packages:
Method 1: Quick installation via ROSDep¶
For each packages, we have referenced all the dependencies in their respective package.xml file, which allow to install each dependency via rosdep command:
rosdep update rosdep install --from-paths src --ignore-src --default-yes --rosdistro melodic --skip-keys "python-rpi.gpio"
Method 2: Full installation¶
ROS packages needed are:
- python-rosinstall python-rosinstall-generator
To install a package on Ubuntu:
sudo apt install <package_name>
Melodic specific packages needed are:
To install a ROS Melodic’s package on Ubuntu:
sudo apt install ros-melodic-<package_name>
Be sure to be still placed in the catkin_ws_niryo_ned folder.
Then perform the make of Ned’s ROS Stack via the command:
If no errors occurred during the make phase, the setup of your environment is almost complete!
It is necessary to source the configuration file to add all Ned packages to ROS environment. To do so, run the command:
It is necessary to run this command each time you launch a new terminal. If you want to make this sourcing appends for all your futur terminals, you can add it to your bashrc file:
echo "source $(pwd)/devel/setup.bash" >> ~/.bashrc source ~/.bashrc
Installation is now finished!
- If you haven’t follow the step of Simulation Environment Installation. you won’t be able to use the simulation.
- Hardware features won’t be accessible.
Without physics - Visualization¶
The visualization happens with Rviz which is a powerful tool.
Control with trackbar¶
This visualization allows an easy first control of the robot, and helps to understand joints disposal. You can access it by using the command:
roslaunch niryo_robot_description display.launch
Rviz should open with a window containing 6 trackbars. Each of these trackbars allows to control the corresponding joint.
Control with ROS¶
To run it:
roslaunch niryo_robot_bringup desktop_rviz_simulation.launch
With physics - Simulation¶
For the simulation, Ned uses Gazebo, a well known tool among the ROS community. It allows:
- World creation → An virtual environment in which the robot can deal with objects.
- Gripper & Camera using.
The Niryo Gripper 1 has been replicated in Gazebo. The Camera is also implemented.
Gazebo also generates camera distortion, which brings the simulation even closer from the reality!
A specific world has been created to use Ned in Gazebo with 2 workspaces.
To run it:
roslaunch niryo_robot_bringup desktop_gazebo_simulation.launch
You can edit Gazebo world to do your own! It’s placed in the folder worlds of the package niryo_robot_gazebo.
The user can disable 3 things by adding the specific string to the command line:
- the Gazebo graphical interface: gui:=false.
- the Camera & the Gripper - Vision & Gripper wise functions won’t be usable: gripper_n_camera:=false.
Gazebo can be very slow. If your tests do not need Gripper and Camera, consider using Rviz to alleviate your CPU.