Firmware for Arduino | PLEN Project Company Inc.
MotionController.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #ifndef PLEN2_MOTION_CONTROLLER_H
11 #define PLEN2_MOTION_CONTROLLER_H
12 
13 
14 #include <stdint.h>
15 
16 #include "JointController.h"
17 
18 namespace PLEN2
19 {
20  namespace Motion
21  {
22  class Header;
23  class Frame;
24  }
25 
26  #ifdef PLEN2_INTERPRETER_H
27  class Interpreter;
28  #endif
29 
30  class MotionController;
31 }
32 
37 {
38 #ifdef PLEN2_INTERPRETER_H
39  friend class Interpreter;
40 #endif
41 
42 public:
48  MotionController(JointController& joint_ctrl);
49 
55  bool playing();
56 
62  bool frameUpdatable();
63 
69  bool updatingFinished();
70 
76  bool nextFrameLoadable();
77 
83  void play(uint8_t slot);
84 
90  void playFrameDirectly(const Motion::Frame& frame);
91 
98  void willStop();
99 
103  void stop();
104 
105  /*
106  @brief Add differences between current-frame and next-frame to current-frame
107  */
108  void updateFrame();
109 
113  void loadNextFrame();
114 
127  void dump(uint8_t slot);
128 
129 private:
130  enum { FRAMEBUFFER_LENGTH = 2 };
131 
132  void m_setupFrame(uint8_t index);
133  void m_bufferingFrame();
134 
135 
136  JointController* m_joint_ctrl_ptr;
137 
138  uint8_t m_transition_count;
139  bool m_playing;
140 
141  Motion::Header m_header;
142  Motion::Frame m_buffer[FRAMEBUFFER_LENGTH];
143  Motion::Frame* m_frame_current_ptr;
144  Motion::Frame* m_frame_next_ptr;
145 
146  int32_t m_current_fixed_points[JointController::JOINTS_SUM];
147  int32_t m_diff_fixed_points[JointController::JOINTS_SUM];
148 };
149 
150 #endif // PLEN2_MOTION_CONTROLLER_H
Definition: AccelerationGyroSensor.h:16
void dump(uint8_t slot)
Dump a motion with JSON format.
Class of a motion header.
Definition: Motion.h:42
MotionController(JointController &joint_ctrl)
Constructor.
bool playing()
Decide if a motion is playing.
Summation of the servos controllable.
Definition: JointController.h:56
void loadNextFrame()
Load next frame.
void playFrameDirectly(const Motion::Frame &frame)
Play a frame directly.
Management class of a motion.
Definition: MotionController.h:36
bool nextFrameLoadable()
Decide if there is a loadable frame at the next time.
Management class of interpreter.
Definition: Interpreter.h:29
Management class of joints.
bool updatingFinished()
Decide that updating a frame has finished.
Management class of joints.
Definition: JointController.h:29
void willStop()
Will stop playing a motion.
void play(uint8_t slot)
Play a motion.
Class of a motion frame.
Definition: Motion.h:123
bool frameUpdatable()
Decide if a motion frame is updatable.
void stop()
Stop playing a motion.