###### tags: `ROS1` `Jetson nano` # Jetfalcon and teleoperation Before controling Jetfalcon, you need to setup the operating environment. If you had not done this step, please go to the last step: [0. Jetfalcon and setup environment](https://hackmd.io/@weichih-lin/jetfalcon_and_setup_environment). ## Hardware you need to prepare A mobile platform with differential drive configuration. If you don't have and idea, please check more information from [Jetfalcon](https://hackmd.io/@weichih-lin/jetfalcon). [![Jetfalcon](https://i.imgur.com/heaSful.jpg)](https://www.icshop.com.tw/product-page.php?27398) OK! Let's see how to use teleoperation! ## 1. Setup operating environment on your host machine. ### 1-1. Install ROS on host machine If you don't have another host machine, you can remote Jetfalcon to do the teleoperation. Host machine must can use ROS, and recommand the version is ROS-Melodic. If you don't have any idea to install ROS on your host machine, please check [ROS Installation](http://wiki.ros.org/ROS/Installation) to install ROS. Below these examples will use ROS-noetic to teleop jetfalcon. ### 1-2. Download the project jetfalcon Please download the project jetfalcon through the command below: ```bash= git clone https://github.com/kjoelovelife/jetfalcon ``` ![Downlaod project jetfalcon](https://i.imgur.com/34C2mSh.png) Next, install the dependencies through the command below: ```bash= source ~/jetfalcon/install/dependencies.sh ``` ![install dpendencies](https://i.imgur.com/MazNgOQ.png) ### 1-3. Install teleop-twist-keyborad The package "teleop-twist-keyboard" is a generic keyboard teleop for twist robots. Please ckeck the [ROS Wiki](http://wiki.ros.org/teleop_twist_keyboard) to install. ### 1-4. Build workspace Next step is building workspace. Please type the command below to build workspace: ```bash= cd ~/jetfalcon/catkin_ws && catkin_make ``` ![Build workspace](https://i.imgur.com/es4wbZZ.png) ### 1-5. Update operating environment in terminal Finally, we must update the operating environment. But first, we should define where the master node activate, host machine or Jetfalcon. In this example, we activate master node on the Jetfalcon for convenience. Therefore, we should setup the varaiable ROS_MASTER_URI on our host machine. Now, please check IP address and hostname on the Jetfalcon. You can type the command below on the Jetfalcon: ```bash= hostname -I ``` ![check IP address](https://i.imgur.com/cEkisRz.png) Accroding to this example, the IP address of the Jetfalcon is "192.168.3.51" and the hostname is "rosky" Next, edit the "$HOSTNAME" in file "~/jetfalcon/setup/environment.sh" with line 18 and 19 > source $workspace/setup/set_ros_master.sh $HOSTNAME > source $workspace/setup/set_vehicle_name.sh $HOSTNAME Here is the example below($HOSTNAME is "rosky" in the example) ![Edit environment.sh](https://i.imgur.com/LJ77XEf.png) Great! The final step is type the command below in the terminal: ```bash= echo "source ~/jetfalcon/setup/environment.sh" >> ~/.bashrc ``` And you also can re-source file "~/.bashrc" or re-opee a nwe terminal to update the operating environment. ![Update environment](https://i.imgur.com/IiIGEtY.png) ## 2. Teleop the Jetfalcon ### 2-1. Use keyboard to control After setting up the operating environment, now we can use ROS to teleop the Jetfalcon. First, remote login the Jetfalcon thorugh SSH or noMachine and more. Here is the example below: ![Remote login](https://i.imgur.com/AZ0vWzy.png) Second, bringup the Jetfalcon thorugh the command below. Remember! Must type the command below on the Jetfalcon: ```bash= roslaunch jetfalcon_bringup bringup.launch ``` ![Bringup the Jetfalcon](https://i.imgur.com/4rAYGXX.png) Finally, use package "teleop_twist_keyboard" thorugh the command below on the host machine: ```bash= rosrun teleop_twist_keyboard teleop_twist_keyboard.py ``` ![Teleop twist keyboard](https://i.imgur.com/GkiKLi5.png) Great! Now you can follow the information on the terminal to control the Jetfalcon! ### 2-2. Calibrate the Jetfalcon Here is the differential drive configuration on the Jetfalcon: > Vright = (gain + trim)(2 * Vx) + (Az * L) / (2 * radius) > Vleft = (gain - trim)(2 * Vx) - (Az * L) / (2 * radius) and > Vright: velocity of the right wheel > Vleft : velocity of the left wheel > gain : controls the maximum speed of the Jetfalcon > trim : controls the balance between the two wheels > Vx : linear velocity of the Jetfalcon > Az : angular velocity of the Jetfalcon > L : length between the right and left wheel > radius: radius of the wheel In this example, we just need to adjust values of "gain" and "trim". Please type the command below in the terminal on the host machine: ```bash= rosrun rqt_reconfigure rqt_reconfigure ``` ![rqt_reconfigure](https://i.imgur.com/YZwNnLS.png) Now, you can adjust the parameter to calibrate the Jetfalcon motion. After you finish adjusting, please type the command below to save the parameters: ```bash= rosservice call /$HOSTNAME/inverse_kinematic/save_calibration ``` Remember the variable "$HOSTNAME" is the hostname of Jetfalcon. ![Save parameters](https://i.imgur.com/whxPNya.png) OK! Now we can go the next unit: [Jetfalcon and SLAM](https://hackmd.io/@weichih-lin/jetfalcon_slam)