Difference between revisions of "AquaShoko"

From Lofaro Lab Wiki
Jump to: navigation, search
(System Install)
Line 6: Line 6:
 
* Ach: [https://github.com/golems/ach] (remember to install the python bindings)
 
* Ach: [https://github.com/golems/ach] (remember to install the python bindings)
 
* ROS
 
* ROS
 +
* Gazebo 8: [http://gazebosim.org/]
  
 
==System Install==
 
==System Install==
Line 12: Line 13:
 
<code>
 
<code>
 
$ git clone https://github.com/thedancomplex/AquaShoko-Gazebo
 
$ git clone https://github.com/thedancomplex/AquaShoko-Gazebo
 +
</code>
 +
 +
Switch to the feature/ach branch
 +
 +
<code>
 +
# git checkout feature/ach
 
</code>
 
</code>
  
Line 23: Line 30:
 
$ make
 
$ make
 
</code>
 
</code>
 +
 +
 +
=Run=
 +
* Open Gazebo
 +
* Add the AquaShoko-Gazebo folder to your path via the "insert" tab
 +
* Insert the model ComplexAquaShokoLongLeg
 +
 +
=Control Via ROS=
 +
In ROS AquaShoko uses the JointState message type to receive commands.  The positions are set via modifying the "position" variable for each joint.
 +
 +
To activate the ROS functionality you must run the ROS controller:
 +
 +
<code>
 +
# python roboControl.py
 +
</code>
 +
 +
==Topic==
 +
* Topic: aquashoko_chatter
 +
* Type: JointState
 +
 +
==Example ROS Controller==
 +
Below is an example ROS controller in Python that sets all joints to 5 degrees.
 +
 +
<source lang="python">
 +
#!/usr/bin/env python
 +
import rospy
 +
from sensor_msgs.msg import JointState
 +
from std_msgs.msg import Header
 +
def talker():
 +
 +
    val = 5
 +
 +
    pub = rospy.Publisher('aquashoko_chatter', JointState, queue_size=10)
 +
    rospy.init_node('aquashoko_talker')
 +
    rate = rospy.Rate(10) # 10hz
 +
    hello_str = JointState()
 +
    hello_str.header = Header()
 +
    hello_str.header.stamp = rospy.Time.now()
 +
    hello_str.name = ['joint00', 'joint01', 'joint02', 'joint10', 'joint11', 'joint12', 'joint20', 'joint21', 'joint22', 'joint30', 'joint31','joint32']
 +
    hello_str.position = [val, val, val, val, val, val, val, val, val, val, val, val]
 +
    hello_str.velocity = []
 +
    hello_str.effort = []
 +
    pub.publish(hello_str)
 +
 +
    i = 0
 +
    while not rospy.is_shutdown():
 +
      hello_str.header.stamp = rospy.Time.now()
 +
      pub.publish(hello_str)
 +
      rate.sleep()
 +
      print i
 +
      i = i+1
 +
 +
if __name__ == '__main__':
 +
    try:
 +
        talker()
 +
    except rospy.ROSInterruptException:
 +
        pass
 +
</source>

Revision as of 04:28, 5 December 2017

About

This tutorial shows you how to install and run AquaShoko in Gazebo via Ach and Ros

Install

Prerequisites

  • Ach: [1] (remember to install the python bindings)
  • ROS
  • Gazebo 8: [2]

System Install

Download the AquaShoko-Gazebo project

$ git clone https://github.com/thedancomplex/AquaShoko-Gazebo

Switch to the feature/ach branch

  1. git checkout feature/ach

Build the project using CMake

$ cd AquaShoko-Gazebo
$ mkdir build
$ cd build
$ cmake ../
$ make


Run

  • Open Gazebo
  • Add the AquaShoko-Gazebo folder to your path via the "insert" tab
  • Insert the model ComplexAquaShokoLongLeg

Control Via ROS

In ROS AquaShoko uses the JointState message type to receive commands. The positions are set via modifying the "position" variable for each joint.

To activate the ROS functionality you must run the ROS controller:

  1. python roboControl.py

Topic

  • Topic: aquashoko_chatter
  • Type: JointState

Example ROS Controller

Below is an example ROS controller in Python that sets all joints to 5 degrees.

#!/usr/bin/env python
import rospy
from sensor_msgs.msg import JointState
from std_msgs.msg import Header
def talker():
 
    val = 5
 
    pub = rospy.Publisher('aquashoko_chatter', JointState, queue_size=10)
    rospy.init_node('aquashoko_talker')
    rate = rospy.Rate(10) # 10hz
    hello_str = JointState()
    hello_str.header = Header()
    hello_str.header.stamp = rospy.Time.now()
    hello_str.name = ['joint00', 'joint01', 'joint02', 'joint10', 'joint11', 'joint12', 'joint20', 'joint21', 'joint22', 'joint30', 'joint31','joint32']
    hello_str.position = [val, val, val, val, val, val, val, val, val, val, val, val]
    hello_str.velocity = []
    hello_str.effort = []
    pub.publish(hello_str)
 
    i = 0
    while not rospy.is_shutdown():
      hello_str.header.stamp = rospy.Time.now()
      pub.publish(hello_str)
      rate.sleep()
      print i
      i = i+1
 
if __name__ == '__main__':
    try:
        talker()
    except rospy.ROSInterruptException:
        pass