Skip to main content

Motion Node

The Motion node is responsible to acting on high level events raised by other nodes, such as the PersonNode, and translating these commands to movements of the robot or the camera:

motionnode.py
loading...

On startup the node subscribes to the high level events:

  • start-looking-around - start the process of looking around
  • stop-looking-around - halt the process of looking around
  • centre-thing - move the robot and camera to centre the detected object in the frame to the centre of the frame

Start Looking Around

This event is triggered when the robot is idle, that is, there has been a period of time when the robot has not detected anything interesting. The response to this event is to start the process of looking around:

Start Looking Around
loading...

The motion node publishes a servo-execute-sequence event with a sequence list described by the method looking_around_sequence():

Looking Around Sequence
loading...

The servo sequence is made up of a list of Camera Command steps. Each of these is an instruction of how to move the camera.

The servo-execute-sequence is then handled by the ServoNode

Stop Looking Around

This event is raised to stop looking around and is typically issued when another node detects an object of interest in the frame:

Stop Looking Around
loading...

The motion node responds to this event by raise a stop camera command.

Centre Thing

In response to the centre-thing event, the motion node attempts to center the thing in the frame with respect to the robot. This involves moving the camera and rotating the robot:

Centre Thing
loading...

To centre the thing, this method determines the X and Y offset of the thing in the frame. To correct the Y offset, the camera is moved up or down. To correct the X offset, the robot is rotated left or right and the camera is moved left or right.

This method is iterative, that is, the method makes a reasonable adjustment to move the thing to the centre of the frame. If the object roughly centred, this method does nothing. If the object is detected again and is not centred, this event will be re-fired and processed. This achieves the following results:

  • Big adjustments, like rotating the robot are performed first. After this, fine adjustments are made using the camera.
  • Over time the object of interest is brought into the centre of the frame
  • If the object moves, it is in effect tracked by this method
  • If another object of interest is detected, this method will centre on the new object.
note

This method is passed a Things Object. This can be a person or another object that the robot is interested in. In all cases, the object has frame data indicating where the object is in the frame.