Skip to content

VISTEC-IST-ROBOTICS-PUBLIC/Stick-insect-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

Stick-insect-simulation

image

(a) Systems

  • Ubuntu 20.04
  • ROS1
  • CoppeliaSim simulation (Education version 4.4.0)

(b) Needed skill

  • Ubuntu command line
  • C++ and Lua languages programming
  • Basic ROS1
    • catkin
    • creat package
    • topic and message
  • Basic CoppeliaSim simulation
    • Create object and joint
    • Create joint
    • Move and rotate an object

(c) Files explaination

image image

(d) Preparing the system

(e) How to run the simulation

In the provided files, we have two simulation system

(1) fixed Leg trajectory simulation

This system contains only medaextra-fixed_CPG.ttt, this system is used to observe the leg trajectory data from a real insect and extract it to robot motor commands. Then, the motor commands are used to be a target in RBF network, and we can obtain RBF weights to transfer CPG signals to motor signals. We can run this simulation file without using ROS1. See the figure for more explanation.

The stick insect system

image

Visibility in the simulation

image

Check the trajectory path

image

(2) The stick insect simulation with self-organized locomotion control

This system uses the remaining files to run the system. We use ROS1 for interfacing (sending motor commands, receiving feedback signals, etc) with the simulation. You can run this system by following the steps below.

  • Change the file path to match my own machine!!!
    • In rbfn.h >> line 51 image
    • In rbfn_semicircle.h >> line 48 image
  • Open a terminal and run "roscore"
  • Open CoppeliaSim >> [see example](https://forum.coppeliarobotics.com/viewtopic.php?t=9148\)
  • In the simulation, Open the scene from the downloaded folder “medaextra_ver2.ttt
  • You will see the stick insect robot, then run ▶️ image

Author: Thirawat Chuthong (Joe) (contact: thirawat.c_s21[at]vistec.ac.th)

Upload CSV file to CoppeliaSim (VREP)

Introduction

In this tutorial, it will be shown how to upload a CSV file to CoppeliaSim (VREP). A script will be used to read the CSV file and create a trajectory for the robot/object that you intend to move.

Prerequisites

  • CoppeliaSim (VREP) installed.
  • CSV file with the trajectory to be followed.
  • CoppeliaSim scene with the robot/object that will follow the trajectory.

Step 1: Create a CSV file with the trajectory to be followe

The CSV file must have the following format:

  • image

For example:

  • image

This is the only format that CoppeliaSim accept for the paths. The first row must contain the names of the columns, and the following rows must contain the values of the trajectory. By using third part programs like excel or google sheets, you can create the CSV file and save it in .csv format.

Step 2: CoppeliaSim scene

In CoppeliaSim scene, you will need to add a dummy object. This object will be the one that will follow the trajectory. (it can be any kind of object, even a primitive shape like cuboids) After adding the dummy object, image

you will need to add this script by right clicking on the dummy object and selecting Add -> Associated child script -> Non-threaded. image

Then, you will need to copy this script to the dummy object script.

  function sysCall_init()
  -- Check current path of your script file
   local currentPath = sim.getStringParam(sim.stringparam_scene_path)
   print(currentPath)
  -- Create an array to store the data
   local csvPath = {}
  -- Open your csv file : relate to your current path
   local file = io.open(currentPath .. "/path&to&your&file.csv", "r")
   print("open")
   if file then
   print("file")
  -- Read and store each line of data in the array
   for line in file:lines() do
   for value in line:gmatch("([^,]+)") do
   table.insert(csvPath, tonumber(value))
   end
   end
  -- Close the file
   file:close()
  -- Now 'csvPath' contains your CSV data in a Lua array
  -- You can use 'csvPath' for further processing in your simulation
   else
   print("Failed to open the file")
   end
   print(csvPath)
  -- This is a simple path you can use this stead of csvPath
   local simPath = {
   0.1,0.1,0.1,0,0,0,1,
   0.2,0.2,0.2,0,0,0,1,
   0.3,0.3,0.3,0,0,0,1,
   0.4,0.4,0.3,0,0,0,1,
   0.5,0.5,0.2,0,0,0,1,
   0.4,0.4,0.1,0,0,0,1,
   0.3,0.3,0.1,0,0,0,1,
   0.2,0.2,0.2,0,0,0,1,
   0.1,0.1,0.3,0,0,0,1}
  -- Create path
   sim.createPath(csvPath,16)
  end

In the script, you will need to change the path to your CSV file. You can do this by changing the following line:

  local file = io.open(currentPath .. "/path&to&your&file.csv", "r")

Step 3: Use the script to read the CSV file and create the trajectory

Now, to exploit the script you will need to run the simulation. After running the simulation, the script will read the CSV file and create the trajectory. To see the trajectory, you will need to select the dummy object and then select the path that was created by the script.

WHEN THE SIMULATION IS STILL RUNNING is possible to copy the path object, stop the simulation and paste the path object in the scene. This way you will be able to see the trajectory without running the simulation

image

Author:

Gian Paolo Currá (contact: gicur22@student.sdu.dk) and Thirawat Chuthong (contact: thirawat.c_s21[at]vistec.ac.th)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors