-
Notifications
You must be signed in to change notification settings - Fork 9
Drive Control
This page contains instructions for running Drive.
First, follow the instructions below for using joystick drive and using the Arduino IDE with ROS.
Then run the following two lines of code:
echo -e "launch_drive() {\n~/catkin_ws/src/rover/scripts/launch_drive.sh\n}" >> ~/catkin_ws/devel/setup.sh
source ~/catkin_ws/devel/setup.sh
Afterwards, launch drive with:
launch_drive
If you want to learn more about the script, add the -h
option after the script or check out the source code at ~/catkin_ws/src/rover/scripts/launch_drive.sh
.
Shortcut commands (works on the rsx laptop and the jetson): nvidia (ssh into nvidia) core (start roscore) drive1 (run drive receiver node) drive2 (run drive sender node)
- Upload the Drive_receiver Arduino code on the Arduino ssh into the nvidia jetson and run roscore
- Run the receiver node in the jetson using this command (***using your port number): rosrun rosserial_python serial_node.py _port:=/dev/ttyACM# _baud:=57600 or drive1
- On the separate command window, use this command: rosrun rover drive_sender or drive2
- Control the rover using the arrow keys
You might run into an issue with the package "rover" not being found. To fix this, close all your terminals and open a new terminal. Then:
- (file editor shortcut command) ~/.bashrc
Go to the bottom and type in these lines:
- source ~/catkin_ws/devel/setup.bash
- export PYTHONPATH/$PYTHONPATH (not completed)
For Virtual box users, the Arduino does not automatically connect to the virtual box and has to be added to the machine. The USB must to forwarded through your computer to the virtual machine. You will know that you need to do this if the ports tab is not accessible when you are trying to change the port.
Follow these steps:
-
Add the USB to your machine
- Have the machine in an idle state and click on machine at the top of the page
- Click on settings
- Click on the ports option
- Click on the USB section
- Check that the USB controller in enabled and that one of the controllers is selected ( the first one 1.1)
- Click the plus USB icon to check that your USB is being detected and add it to the list
- Restart the virtual machine and open terminal
-
Follow the rest of this tutorial to make a vboxusers group on your virtual machine (also included the first set of instructions)
https://www.youtube.com/watch?v=saR-nVRV5rk
- If when trying to upload, an error comes out that the permission for the port has been denied then follow this video
https://www.youtube.com/watch?v=mEptke-5rJc
This error results when trying to run drive and you don't have rosserial_python installed. Look at the readME for more information.
Resulting Error: [rospack] Error: package 'rosserial_python' not found
-
First remove any previous rosserial files that don't say they cannot be removed. Then install the rosserial package using this command: "sudo apt-get install ros-melodic-rosserial-*" (this will install all including the rosserial_python that we need)
-
Now we can rosrun:
rosrun rosserial_python serial_node.py _port:=/dev/tty(yourport) _baud:= 57600
-
Install the joystick package and configure the joystick: http://wiki.ros.org/joy/Tutorials/ConfiguringALinuxJoystick
-
Installing the Package sudo apt-get install ros-melodic-joy
- ls /dev/input/
should see jsX (X is a number, usually 0 - this is your joystick) - sudo jstest /dev/input/jsX
move joystick around to test it - ls -l /dev/input/jsX
if XX is rw: the js device is configured properly. if XX is --: the js device is not configured properly and you need to: sudo chmod a+rw /dev/input/js0
- roscore
- rosparam set joy_node/dev "/dev/input/jsX"
- rosrun joy joy_node
- In new terminal to test: rostopic echo joy
- Install Arduino IDE by using this command :
- sudo apt-get install arduino arduino-core
Install rosserial with these two lines :
- sudo apt-get install ros-melodic-rosserial-arduino
- sudo apt-get install ros-melodic-rosserial
Change directory to catkin_ws/src :
- git clone https://github.com/ros-drivers/rosserial.git
- Go back to catkin_ws
- catkin_make
Change directory to /home/sketchbook/libraries :
- rm -rf ros_lib. You can checkout your sketchbook folder through opening Arduino IDE, file, preference
- run rosrun rosserial_arduino make_libraries.py .
*** Make sure to include the . at the end of the command
When you open the Arduino IDE, ros_lib should be under File/Examples
If the serialport doesn’t show up, then restart the computer.
To test, upload HelloWorld file from the aruduino ros_lib to the arduino, do roscore, then rosrun rosserial_python serial_node.py /dev/ttyACM# (where # is the port number of the Arduino shown in the Arduino IDE) to run the Arduino as a ROS node
Open another terminal and enter command rostopic echo chatter to see the text message.
*** Set the baud rate to 57600 when using the drive arduino code. (Or when this error shows up: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino)
You can also try directly getting the rosserial library through arduino if it doesn’t show up after this.
Go into sketch, go to include library and click manage libraries. Search for rosserial and click install. Then it should definitely show up.
/* For joystick */
After the command "rosrun joy joy_node", if you get the error:
"[ERROR] [1580579912.157133017]: Couldn't open joystick force feedback!
[ INFO] [1580579912.158771272]: Opened joystick: /dev/input/js0. deadzone_: 0.050000. "
just ignore it. It doesn't matter and does not cause any issues.
[To be edited....]
http://wiki.ros.org/joy/Tutorials/ConfiguringALinuxJoystick (Link for initial setup of a linux compatible joystick)
Check this link: https://ubuntu.com/tutorials/install-the-arduino-ide#1-overview
*Note: might need to replace "ACM" with "USB"
The keybindings read from the Joy topic
axes (float values): [left stick {-1.0 when right -- 1.0 when left}, left stick {-1.0 when down -- 1.0 when up}, L2 {-1.0 when pressed -- 1.0 when not pressed}, right stick {-1.0 when right -- 1.0 when left},right stick {-1.0 when down -- 1.0 when up} , R2 {-1.0 when pressed -- 1.0 when not pressed}]
buttons (binary): [X, Circle, Triangle, Square, L1, R1, L2, R2, select, start, power, left joy press, right joypress, up dpad, down dpad, left dpad, right dpad]
Wondering how to make nice formatting? Check out this guide!