Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,35 @@ Nvidia Jeston TX2/Xavier/XavierNX have CAN controller(s) integrated in the main
# receiving data from can0
$ candump can0
```
---------------------------------------------------------------------------------

**Alternatives to 3:**
1) Add into bunker_robot_base.launch:
```
<node name="setup_can_interface" pkg="bunker_bringup" type="bringup_can2usb.bash" output="screen" />
```
* The ROS environment is set up to handle password prompts, or configure sudo to allow these commands to execute without a password. This can be done by editing the sudoers file (using sudo visudo) like so:
```
$ sudo visudo
```
* And adding a line for specific commands to be run without a password:
```
<username> ALL=(ALL) NOPASSWD: /sbin/modprobe, /sbin/ip link set can0 up type can bitrate 500000
```
OR

2) Run the shellscript:
```
$ sudo ./bunker_pro.sh
```
*Note*: modify bunker_pro.sh:
```
# Replace '/opt/ros/noetic' with your actual ROS distribution path.
source /opt/ros/noetic/setup.bash
# Replace '/home/ara/bunker_ws' with your actual ROS ws path.
source /home/ara/bunker_ws/devel/setup.bash
```
---------------------------------------------------------------------------------

4. Launch ROS nodes

Expand Down
2 changes: 2 additions & 0 deletions bunker_bringup/launch/bunker_robot_base.launch
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<arg name="is_bunker_mini" default="false" />
<arg name="pub_tf" default="true" />

<node name="setup_can_interface" pkg="bunker_bringup" type="bringup_can2usb.bash" output="screen" />

<include file="$(find bunker_base)/launch/bunker_base.launch">
<arg name="port_name" default="$(arg port_name)" />
<arg name="simulated_robot" default="$(arg simulated_robot)" />
Expand Down
42 changes: 42 additions & 0 deletions bunker_bringup/scripts/bunker_pro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Check for root permissions
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" >&2
exit 1
fi

# Source the ROS environment
# Replace '/opt/ros/noetic' with your actual ROS distribution path.
source /opt/ros/noetic/setup.bash
# Replace '/home/ara/bunker_ws' with your actual ROS ws path.
source /home/ara/bunker_ws/devel/setup.bash

# Load the gs_usb kernel module if not already loaded
if ! lsmod | grep -q gs_usb; then
echo "Loading gs_usb module..."
sudo modprobe gs_usb
else
echo "gs_usb module already loaded."
fi

# Set up the can0 device with a specified bitrate if not already set
# Check if can0 is already up with the correct settings
current_bitrate=$(ip -details link show can0 | grep -oP 'bitrate \K[^ ]+' || echo "down")

if [[ $current_bitrate != "500000" ]]; then
echo "Setting up CAN0 interface..."
sudo ip link set can0 up type can bitrate 500000
if [ $? -eq 0 ]; then
echo "CAN0 interface setup successful."
else
echo "Failed to set up CAN0 interface." >&2
exit 2
fi
else
echo "CAN0 interface already set up with correct bitrate."
fi

# Launch the ROS nodes
echo "Launching ROS nodes..."
roslaunch bunker_bringup bunker_robot_base.launch