Erle-Spider

Erle-Spider simulation is a Work in Progress, if you're interested in contributing please do so by submitting Pull Requests to https://github.com/erlerobot/ros_erle_spider.

Install the following packages:

sudo apt-get install ros-indigo-rviz
sudo apt-get install ros-indigo-ros-control
sudo apt-get install ros-indigo-robot-state-publisher

First, we are going to create a new workspace for the spider:

mkdir -p ~/simulation/spider_ws/src
cd ~/simulation/spider_ws/src
catkin_init_workspace
cd ~/simulation/ros_catkin_ws
catkin_make_isolated
source devel_isolated/setup.bash

Download and compile the node:

cd src/
git clone https://github.com/erlerobot/ros_erle_spider
cd ..
source devel_isolated/setup.bash
catkin_make_isolated

To launch the simulation run:

cd ~/simulation/spider_ws
source devel_isolated/setup.bash
roslaunch spider_gazebo spider_gazebo_rviz_walking.launch

This will bring up two windows, Gazebo and Rviz.

Figure 1 - Erle-Spider model in Gazebo simulator
Figure 2 - Erle-Spider model in Rviz

To control the spider you can either:

  1. Use a game path controller
  2. Use ROS

You can use any game path controller that is supported by Linux. For instance, a PS3 controller. To do so, plug the joystick via usb and relaunch the simulation.

Once the spider is spawned, press START to stand it up and use the joysticks to move it.

If you happen not to have a game path controller, you can just control the spider via ROS. For instance, you can make the spider to stand up by running the following script (paste the following code into a file called spider_stand_up.py and then run python spider_stand_up.py in the same directory):

import rospy
import sys
import time
from spider_msgs.msg import *
from sensor_msgs.msg import Joy

rospy.init_node('spider_stand_up', anonymous=True)

standup_time=20

################
## INITIALIZE ##
################
pub = rospy.Publisher('/joy', Joy, queue_size=10)
msg = Joy()
msg.header.stamp = rospy.Time.now()
rate = rospy.Rate(10)

valueAxe = 0.0
valueButton = 0
for i in range (0, 20):
    msg.axes.append(valueAxe)
for e in range (0, 17):
    msg.buttons.append(valueButton)

####################
## STAND UP       ##
####################
msg.buttons[3] = 1
i=0
bo=True
standup_time=standup_time/3
while not rospy.is_shutdown() and bo:
    i=i+1
    if (i>standup_time):
      bo=False
      msg.buttons[3] = 0
    pub.publish(msg)
    rate.sleep()
time.sleep(2)

To make it move forward, paste the following code into spider_forward.py and run python spider_forward.py in the same directory:

import sys
import time
from spider_msgs.msg import apm_imu
from spider_msgs.msg import BodyCommand
from spider_msgs.msg import BodyState
from spider_msgs.msg import GaitCommand
from spider_msgs.msg import LegIKRequest
from spider_msgs.msg import LegJointsState
from spider_msgs.msg import LegPositionState
from spider_msgs.msg import LegsJointsState
from sensor_msgs.msg import Joy

import rospy

seconds = 10

rospy.init_node('spider_forward', anonymous=True)

################
## INITIALIZE ##
################
pub = rospy.Publisher('/joy', Joy, queue_size=10)
msg = Joy()
msg.header.stamp = rospy.Time.now()
rate = rospy.Rate(10)

valueAxe = 0.0
valueButton = 0
for i in range (0, 20):
 msg.axes.append(valueAxe)
for e in range (0, 17):
 msg.buttons.append(valueButton)

################
##    WALK    ##
################
walking_time=float(seconds)+0.4 ##manual time calibration

start = time.time()

msg.axes[1] = 1

bo=True
while not rospy.is_shutdown() and bo:
 sample_time = time.time()
 if ((sample_time - start) > walking_time):
  bo=False
  msg.axes[0] = 0
  msg.axes[1] = 0
 pub.publish(msg)
 rate.sleep()