Answers.Body: <p>You could use worm gears, or worm gears, or compound worm gears, because you can slow the rotation down as much as you want, which means you can have super fine rotation.</p>
  
  <p>An extreme example of this would be the 120 years timer <a href="https://www.youtube.com/watch?v=6PH7DKk8faY" rel="nofollow noreferrer">here</a></p>
  
  <p>This uses a compound worm gear and spur gear train.</p>
  
  <p>Worm gears also have a lot of torque in a small space.</p>
  
  <p>if you want the snake to sway left but then automatically sway right then just hook do something like <a href="https://www.youtube.com/watch?v=84Nswqm7D2A" rel="nofollow noreferrer">this</a> but like the following: <a href="https://i.sstatic.net/YuWCL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/YuWCL.png" alt="enter image description here"></a></p>
  
  <p>The red pin goes to the snakes body which should 'sway' because of the linkages converting rotary motion into oscillating motion. just make sure that the other half of the snakes body is anchored to the motors housing other wise it will be a retarded snake :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-23T08:32:26.783Z
Answers.LastActivityDate: 2019-04-23T08:48:19.967Z
Answers.LastEditDate: 2019-04-23T08:48:19.967Z
Answers.UserDisplayName: TechnicTechnician
Body: <p>I want to create an EV3 robot similar to this:</p>
  
  <p><a href="http://www.inm.uni-stuttgart.de/mitarbeiter/leine/toys/lego_snake_robot.en.html" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bx156.jpg" alt="snake robot"></a></p>
  
  <p>I've glanced at the mentioned papers. To me it seems that some simpler equations to govern the motors will work also.</p>
  
  <p>I have 9 segments, articulated by 8 motors (two intelligent bricks daisy-chained).</p>
  
  <p>I want the angles of the segments to be proportional to a sine. Doing some calculations in some graphing software, this should be sufficient to have the snake move in a wave.</p>
  
  <p>However, there seems to be no robust, reliable way to set an angle on an EV3 motor. I have a MoveTo myblock, where I use the motor first as angle sensor, calculate the difference to the desired angle and then set the motor "on" for that amount. I also tried setting the power proportional to the difference. But I do not succeed is setting the angle accurate enough, it starts drifting or overshoots. I can't synchronize all the segments that way.</p>
  
  <p>Is it feasible to attempt this in the graphic programming language that comes with the ev3 software or do I need to look to something more advanced?</p>
  
  <p>Any hints would be appreciated.</p>
  
  <p>Edit: Made some headway, rather than putting the motor "On" for a number of degrees, I simply place the motor "On" with a power proportional to the error between the measured angle and desired angle. Works good enough for now. This is the P in a PID-controller, adding an integration and derivative part might help.
  The problem I'm currently facing is the weight distribution, the segment that is the head of the snake doesn't have a motor and hence is much lighter. I need to find a better set of factors to multiply the errors with for each motor. I'm confident I'll succeed in this by trial and error whenever I find the time.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-09T04:09:09.267Z
Comments.Text: I would try to have tape on each segment at 45° angles and have the color sensor read it. May or may not work, but it is at least half an idea. I would go for an arduino or something though to help, or do the entire snake.
Comments.UserDisplayName: Grant Davis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-10T17:15:02.510Z
Comments.Text: Welcome to LEGO Answers! Even if you use the same amount of power each time you may get wildly different results depending on the friction of the surface and the arrangement of the motors. You may need to constantly query the data from the rotation sensor(s) to see if it is aligned, and if not perform corrections, making clockwise/counter-clockwise rotations to get a more precise arrangement. Are you able to show us what your program looks like at the moment?
Comments.UserDisplayName: Ambo100
Tags: <ev3><robotic>
Title: How can body segments be moved to precise angles in snake robot?
UserDisplayName: Michael Verschaeve
ThreadText: # How can body segments be moved to precise angles in snake robot?
  
  (Asked by: username_0 on 2017-02-08)
  
  I want to create an EV3 robot similar to this:
  
  [![snake robot](https://i.sstatic.net/bx156.jpg)](http://www.inm.uni-stuttgart.de/mitarbeiter/leine/toys/lego_snake_robot.en.html)
  
  I've glanced at the mentioned papers. To me it seems that some simpler equations to govern the motors will work also.
  
  I have 9 segments, articulated by 8 motors (two intelligent bricks daisy-chained).
  
  I want the angles of the segments to be proportional to a sine. Doing some calculations in some graphing software, this should be sufficient to have the snake move in a wave.
  
  However, there seems to be no robust, reliable way to set an angle on an EV3 motor. I have a MoveTo myblock, where I use the motor first as angle sensor, calculate the difference to the desired angle and then set the motor "on" for that amount. I also tried setting the power proportional to the difference. But I do not succeed is setting the angle accurate enough, it starts drifting or overshoots. I can't synchronize all the segments that way.
  
  Is it feasible to attempt this in the graphic programming language that comes with the ev3 software or do I need to look to something more advanced?
  
  Any hints would be appreciated.
  
  Edit: Made some headway, rather than putting the motor "On" for a number of degrees, I simply place the motor "On" with a power proportional to the error between the measured angle and desired angle. Works good enough for now. This is the P in a PID-controller, adding an integration and derivative part might help.
  The problem I'm currently facing is the weight distribution, the segment that is the head of the snake doesn't have a motor and hence is much lighter. I need to find a better set of factors to multiply the errors with for each motor. I'm confident I'll succeed in this by trial and error whenever I find the time.
  
  **Tags:** ev3, robotic
  > **Comments:**
  > **username_1**: I would try to have tape on each segment at 45° angles and have the color sensor read it. May or may not work, but it is at least half an idea. I would go for an arduino or something though to help, or do the entire snake.  
  > **username_2**: Welcome to LEGO Answers! Even if you use the same amount of power each time you may get wildly different results depending on the friction of the surface and the arrangement of the motors. You may need to constantly query the data from the rotation sensor(s) to see if it is aligned, and if not perform corrections, making clockwise/counter-clockwise rotations to get a more precise arrangement. Are you able to show us what your program looks like at the moment?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2019-04-23. Score: 1
  
  You could use worm gears, or worm gears, or compound worm gears, because you can slow the rotation down as much as you want, which means you can have super fine rotation.
  
  An extreme example of this would be the 120 years timer [here](https://www.youtube.com/watch?v=6PH7DKk8faY)
  
  This uses a compound worm gear and spur gear train.
  
  Worm gears also have a lot of torque in a small space.
  
  if you want the snake to sway left but then automatically sway right then just hook do something like [this](https://www.youtube.com/watch?v=84Nswqm7D2A) but like the following: [![enter image description here](https://i.sstatic.net/YuWCL.png)](https://i.sstatic.net/YuWCL.png)
  
  The red pin goes to the snakes body which should 'sway' because of the linkages converting rotary motion into oscillating motion. just make sure that the other half of the snakes body is anchored to the motors housing other wise it will be a retarded snake :)
  
  
  ---
  
  