kyrofa / edukit_bot

Final snap of Your First Robot series software.
https://kyrofa.com/posts/your-first-robot-a-beginner-s-guide-to-ros-and-ubuntu-core-1-5
1 stars 1 forks source link

Not able to control edukit_bot with Snap package #1

Open droter opened 4 years ago

droter commented 4 years ago

Hi Kyle,

Thanks for making this tutorial. It is a bunch of fun and I am learning a lot also.

I tried running the robot from your edukit-bot-kyrofa snap package but it won't drive the robot.

(classic)ros-a@localhost:~$ sudo snap install edukit-bot-kyrofa 
edukit-bot-kyrofa 1.0 from Kyle Fazzari (kyrofa) installed
(classic)ros-a@localhost:~$ sudo snap connect edukit-bot-kyrofa:joystick 
(classic)ros-a@localhost:~$ sudo snap connect edukit-bot-kyrofa:physical-memory-control 
(classic)ros-a@localhost:~$ sudo snap restart edukit-bot-kyrofa
Restarted.

Everything works great from your source running from roslaunch.

Any ideas on getting the snap package to work?

Matt

kyrofa commented 4 years ago

So to clarify, it works from source, but the snap doesn't work? Let's take a look at the output from the service (which just runs the launch file):

$ journalctl --no-pager -n100 -u snap.edukit-bot-kyrofa.launch.service
droter commented 4 years ago

Yes, it will work when I manually start the edukit_bot with roslaunch from source. But not with the Snap.

$ sudo journalctl --no-pager -n100 -u snap.edukit-bot-kyrofa.launch.service-- Logs begin at Mon 2020-03-16 16:07:50 UTC, end at Mon 2020-03-16 17:41:41 UTC. -- Mar 16 17:39:54 localhost systemd[1]: Started Service for snap application edukit-bot-kyrofa.launch. Mar 16 17:41:26 localhost edukit-bot-kyrofa.launch[815]: [driver-4] process has died [pid 1054, exit code -11, cmd /snap/edukit-bot-kyrofa/18/opt/ros/kinetic/lib/edukit_bot/driver_node name:=driver log:=/root/snap/edukit-bot-kyrofa/18/ros/log/57ae1b60-67ad-11ea-94be-b827eb6581a1/driver-4.log]. Mar 16 17:41:26 localhost edukit-bot-kyrofa.launch[815]: log file: /root/snap/edukit-bot-kyrofa/18/ros/log/57ae1b60-67ad-11ea-94be-b827eb6581a1/driver-4*.log

ros-a@localhost:~$ sudo tail /root/snap/edukit-bot-kyrofa/18/ros/log/57ae1b60-67ad-11ea-94be-b827eb6581a1/driver-4.log [xmlrpc][INFO] 2020-03-16 17:41:25,944: XML-RPC server binding to 0.0.0.0:0 [xmlrpc][INFO] 2020-03-16 17:41:25,952: Started XML-RPC server [http://192.168.43.161:41361/] [rospy.init][INFO] 2020-03-16 17:41:25,953: ROS Slave URI: [http://192.168.43.161:41361/] [rospy.impl.masterslave][INFO] 2020-03-16 17:41:25,954: _ready: http://192.168.43.161:41361/ [rospy.registration][INFO] 2020-03-16 17:41:25,960: Registering with master node http://localhost:11311 [xmlrpc][INFO] 2020-03-16 17:41:25,961: xml rpc node: starting XML-RPC server [rospy.init][INFO] 2020-03-16 17:41:26,055: registered with master [rospy.rosout][INFO] 2020-03-16 17:41:26,057: initializing /rosout core topic [rospy.rosout][INFO] 2020-03-16 17:41:26,077: connected to core topic /rosout [rospy.simtime][INFO] 2020-03-16 17:41:26,092: /use_sim_time is not set, will not subscribe to simulated time [/clock] topic

I thought the problem might be caused by a remote roscore. ROS_MASTER_URI was set to another machine.

I changed the .bashrc file back to localhost and restarted but it didn't help.

droter commented 4 years ago

I tried reloading Ubuntu Core on a new sd card but got the same result.

ros-a@localhost:~$ snap refresh
All snaps up to date.
ros-a@localhost:~$ sudo snap install edukit-bot-kyrofa
edukit-bot-kyrofa 1.0 from Kyle Fazzari (kyrofa) installed
ros-a@localhost:~$ sudo snap connect edukit-bot-kyrofa:joystick
ros-a@localhost:~$ sudo snap connect edukit-bot-kyrofa:physical-memory-control
ros-a@localhost:~$ sudo snap restart edukit-bot-kyrofa
Restarted.
ros-a@localhost:~$ journalctl --no-pager -n100 -u snap.edukit-bot-kyrofa.launch.service
Hint: You are currently not seeing messages from other users and the system.
      Users in the 'systemd-journal' group can see all messages. Pass -q to
      turn off this notice.
No journal files were opened due to insufficient permissions.
ros-a@localhost:~$ sudo journalctl --no-pager -n100 -u snap.edukit-bot-kyrofa.launch.service
-- Logs begin at Tue 2020-03-17 19:43:26 UTC, end at Tue 2020-03-17 21:18:42 UTC. --
Mar 17 21:16:07 localhost systemd[1]: Started Service for snap application edukit-bot-kyrofa.launch.
Mar 17 21:16:17 localhost edukit-bot-kyrofa.launch[2734]: [ERROR] [1584479777.685912469]: Couldn't open joystick /dev/input/js0. Will retry every second.
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]: Traceback (most recent call last):
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:   File "/snap/edukit-bot-kyrofa/18/opt/ros/kinetic/lib/edukit_bot/driver_node", line 121, in <module>
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:     main()
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:   File "/snap/edukit-bot-kyrofa/18/opt/ros/kinetic/lib/edukit_bot/driver_node", line 114, in main
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:     driver = Driver()
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:   File "/snap/edukit-bot-kyrofa/18/opt/ros/kinetic/lib/edukit_bot/driver_node", line 61, in __init__
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:     self._left_motor = Motor(10, 9)
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:   File "/snap/edukit-bot-kyrofa/18/opt/ros/kinetic/lib/edukit_bot/driver_node", line 31, in __init__
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]:     GPIO.setup(forward_pin, GPIO.OUT)
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]: RuntimeError: No access to /dev/mem.  Try running as root!
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]: [driver-4] process has died [pid 2799, exit code 1, cmd /snap/edukit-bot-kyrofa/18/opt/ros/kinetic/lib/edukit_bot/driver_node __name:=driver __log:=/root/snap/edukit-bot-kyrofa/18/ros/log/87af9cd4-6894-11ea-9c89-b827eb6581a1/driver-4.log].
Mar 17 21:16:18 localhost edukit-bot-kyrofa.launch[2734]: log file: /root/snap/edukit-bot-kyrofa/18/ros/log/87af9cd4-6894-11ea-9c89-b827eb6581a1/driver-4*.log
Mar 17 21:17:23 localhost systemd[1]: Stopping Service for snap application edukit-bot-kyrofa.launch...
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: ... logging to /root/snap/edukit-bot-kyrofa/18/ros/log/87af9cd4-6894-11ea-9c89-b827eb6581a1/roslaunch-localhost-2734.log
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: Checking log directory for disk usage. This may take awhile.
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: Press Ctrl-C to interrupt
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: Done checking log file disk usage. Usage is <1GB.
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: [89B blob data]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: started roslaunch server http://192.168.43.160:38777/
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: SUMMARY
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: ========
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: PARAMETERS
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:  * /joystick/autorepeat_rate: 1
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:  * /joystick_to_twist/scale_angular: 4
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:  * /rosdistro: kinetic
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:  * /rosversion: 1.12.12
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: NODES
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:   /
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:     driver (edukit_bot/driver_node)
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:     joystick (joy/joy_node)
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]:     joystick_to_twist (teleop_twist_joy/teleop_node)
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: auto-starting new master
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: process[master]: started with pid [2781]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: ROS_MASTER_URI=http://localhost:11311
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: [112B blob data]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: setting /run_id to 87af9cd4-6894-11ea-9c89-b827eb6581a1
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: process[rosout-1]: started with pid [2794]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: started core service [/rosout]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: process[joystick-2]: started with pid [2797]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: process[joystick_to_twist-3]: started with pid [2798]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: process[driver-4]: started with pid [2799]
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: [joystick_to_twist-3] killing on exit
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: [joystick-2] killing on exit
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: [rosout-1] killing on exit
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: [master] killing on exit
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: shutting down processing monitor...
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: ... shutting down processing monitor complete
Mar 17 21:17:24 localhost edukit-bot-kyrofa.launch[2734]: done
Mar 17 21:17:24 localhost systemd[1]: Stopped Service for snap application edukit-bot-kyrofa.launch.
Mar 17 21:17:24 localhost systemd[1]: Started Service for snap application edukit-bot-kyrofa.launch.
Mar 17 21:17:30 localhost edukit-bot-kyrofa.launch[3010]: [driver-4] process has died [pid 3110, exit code -11, cmd /snap/edukit-bot-kyrofa/18/opt/ros/kinetic/lib/edukit_bot/driver_node __name:=driver __log:=/root/snap/edukit-bot-kyrofa/18/ros/log/b383414e-6894-11ea-905a-b827eb6581a1/driver-4.log].
Mar 17 21:17:30 localhost edukit-bot-kyrofa.launch[3010]: log file: /root/snap/edukit-bot-kyrofa/18/ros/log/b383414e-6894-11ea-905a-b827eb6581a1/driver-4*.log
ros-a@localhost:~$ 
kyrofa commented 4 years ago

Alright, bear with me, this looks a little insane. First of all, stop the snap:

$ sudo snap stop edukit-bot-kyrofa

Then run this command, and paste the results:

$ cat /snap/edukit-bot-kyrofa/current/command-launch.wrapper | sed 's/exec.*/exec rosrun edukit_bot driver_node/' | sudo snap run --shell edukit-bot-kyrofa.launch
droter commented 4 years ago
ros-a@localhost:~$ sudo snap stop edukit-bot-kyrofa
Stopped.
ros-a@localhost:~$ cat /snap/edukit-bot-kyrofa/current/command-launch.wrapper | sed 's/exec.*/exec rosrun edukit_bot driver_node/' | sudo snap run --shell edukit-bot-kyrofa.launch
Unable to register with master node [http://localhost:11311]: master may not be running yet. Will keep trying.
kyrofa commented 4 years ago

Oh that was silly. Okay try this. Stop the snap:

$ sudo snap stop edukit-bot-kyrofa

Run this in one terminal:

$ cat /snap/edukit-bot-kyrofa/current/command-launch.wrapper | sed 's/exec.*/exec roscore/' | sudo snap run --shell edukit-bot-kyrofa.launch

Run this in another terminal:

$ cat /snap/edukit-bot-kyrofa/current/command-launch.wrapper | sed 's/exec.*/exec rosrun edukit_bot driver_node/' | sudo snap run --shell edukit-bot-kyrofa.launch
droter commented 4 years ago

roscore started okay with the first one.

Now the second one shows segmentation fault: ros-a@localhost:~$ cat /snap/edukit-bot-kyrofa/current/command-launch.wrapper | sed 's/exec.*/exec rosrun edukit_bot driver_node/' | sudo snap run --shell edukit-bot-kyrofa.launch Segmentation fault

kyrofa commented 4 years ago

Hey, we're making progress! Can I see the output of snap version, please?

droter commented 4 years ago

ros-a@localhost:~$ snap --version snap 2.43.3 snapd 2.43.3 series 16 kernel 5.3.0-1019-raspi2

Ubuntu Core 18

kyrofa commented 4 years ago

Ah, I worked all this with Ubuntu Core 16, I'll get 18 flashed and see if I can reproduce.