Skip to content

Basic Rover - Software

Link to module repo: Basic Rover Software


Overview

The basic rover comprises two steered wheels of type ost23. It further has a GNSS receiver input and can be controlled by ... The rover can alternatively be remotely controlled by a FrSky Taranix X7.

The architectural setup follows the system given under architecture overview. The lower level system with EEROS/PLC has the following structure.

ControlSystem The control system has three timedomains running with different periods as shown in the figure.

The safety system is as follows.

SafetySystem

Upon powering up the system will stay in safety level idle. As soon as the remote control starts sending twist signals or twist signals are received from ROS, the wheels will be enabled and the rover starts moving. When either inputs stops receiving signals the wheels are disabled and the system returns to safety level idle. If the rovers runs receiving twist messages from ROS the remote control can immediately take over. However, when the remote control stops the system will always return to idle before it could possibly be controlled by ROS again.

Emergency Stop

The emergency button is directly connected to the drives. At the same time it is read in by the control system as a digital input. It is used to immediately switch to safety level emergency when activated. The rover will leave the emergency level as soon as the emergency button is released. The system will return to idle state.

The higher level system ... TO BE DONE

Simulate the behavior of the basic rover

When the hardware of the rover is not available, the behavior can be simulated using various means. The following missing peripherals must be accounted for:

  • CAN connection to the wheels
  • Remote control through SBUS
  • GPIOs for safety relais input and LED outputs

CAN

Use the CANsimulator. Bring the vcan0 interface up and start the simulator in a separate shell.

Remote Control

Use the SBUS Simulator. Start it in a seperate shell.

GPIO

Use gpio-sim to create virtual GPIO chips and lines. Load the kernel module and create necessary lines as follows:

sudo modprobe gpio-sim
sudo mkdir /sys/kernel/config/gpio-sim/ofagpio 
sudo mkdir /sys/kernel/config/gpio-sim/ofagpio/bank0
echo 32 | sudo tee /sys/kernel/config/gpio-sim/ofagpio/bank0/num_lines
echo 1 | sudo tee /sys/kernel/config/gpio-sim/ofagpio/live

Make sure that you have the right privileges on the device file, e.g. by

sudo chown $USER:$USER /dev/gpiochip0

Now you can pull the line 23 down or up with

echo pull-down | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio23/pull
echo pull-up | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio23/pull
The line must be up for the rover to run.

ROS

Use the following script to publish ROS twist messages under the topic /cmd_vel

import rclpy
from rclpy.node import Node
from geometry_msgs.msg import TwistStamped

rclpy.init()
node = Node('twist_pub')
pub = node.create_publisher(TwistStamped, '/cmd_vel', 10)

import time
for i in range(500):  # Publish 500 messages
    msg = TwistStamped()
    msg.header.stamp = node.get_clock().now().to_msg()
    msg.header.frame_id = 'base_link'
    msg.twist.linear.x = 0.5
    msg.twist.angular.z = 0.3
    pub.publish(msg)
    print(f'Published {i}: {msg.header.stamp.sec}.{msg.header.stamp.nanosec:09d}')
    time.sleep(0.1)  # 10 Hz

rclpy.shutdown()